为什么(;;)代替,而(1)? [英] why for(;;) instead of while(1)?

查看:143
本文介绍了为什么(;;)代替,而(1)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:结果
  <一href=\"http://stackoverflow.com/questions/2611246/is-for-faster-than-while-true-if-not-why-do-people-use-it\">Is &ldquo;对于(;;)rdquo;的比&ldquo快;而(TRUE)&rdquo ;?如果不是,为什么人们使用它?

为什么要使用,而不是稍显好看,而(真)循环丑为(;;)语法?

Why use the ugly for(;;) syntax instead of the slightly better looking while(true) loop?

推荐答案

有没有好处为(;;)而(1 )
使用而(1),因为它更容易COM prehend(恕我直言)。我从来没有见过一个为(;;)使用之前,它可能会产生混淆别人谁查看您的code和可能只是想知道同样的事情,你问。

There is no advantage to for(;;) over while(1). Use while(1), because it's easier to comprehend (imho). I've never seen a for(;;) used before, and it may be confusing to others who view your code, and may wonder the same thing you just asked.

编辑:这里有一个链接:<一个href=\"http://stackoverflow.com/questions/885908/while-1-vs-for-is-there-a-speed-difference\">http://stackoverflow.com/questions/885908/while-1-vs-for-is-there-a-speed-difference

Here's a link: http://stackoverflow.com/questions/885908/while-1-vs-for-is-there-a-speed-difference

这基本上说,他们都产生相同的code。在装配时,它的 JMP ...

It basically says that they both generate the same code. In assembly, it's jmp ....

这篇关于为什么(;;)代替,而(1)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆