Re: what does two semicolns ';;' do



On Mon, 30 Jun 2008 15:05:02 GMT, jimp@xxxxxxxxxxxxxxxxxxxx wrote:
Peter H. Coffin <hellsop@xxxxxxxxxxxxx> wrote:
On Mon, 30 Jun 2008 03:35:01 GMT, jimp@xxxxxxxxxxxxxxxxxxxx wrote:
Tim Roberts <timr@xxxxxxxxx> wrote:
jimp@xxxxxxxxxxxxxxxxxxxx wrote:
larry@xxxxxxxxxxxxxxxxx wrote:

I am looking at some code which process an uploaded file and it has
loops like:

for(;;){ // for([two semicolons){

what is the function of the two semicolons? loop until break?

Yeah, same as while (1) {.

AIR for(;;) is slightly more efficient/faster than while(1).

That's silly. Think about it for a moment. How on earth could that
possibly be true? Both statements translate to exactly one assembly
instruction: a "jmp".

True if there is optimization going on.

Okay:

That's silly. Think about it for a moment. How on earth could that
possibly be reliably true? Both statements can easily translate to
exactly one assembly instruction: a "jmp".

Better?

You're missing the point.

While it is obviously true that whatever is translating the code COULD
do that, not all translators/compilers actually DO that.

Here's another case:

i=1;

while (i) {
// i never changes
}

Some compilers/translators will recognize this is an infinite loop
and some won't.

It all bepends on how clever the compiler/translator is.

Exactly. Since we're presuming we don't know how clever the compiler is
exactly, it's therefore silly to claim that for(;;) is slightly more
efficient/faster than while(1). The compiler could handle both the same
way, in which case they'd be the same speed in execution.

--
Liberty, equality, diversity. Pick any two.
.



Relevant Pages

  • Re: what does two semicolns ;; do
    ... AIR foris slightly more efficient/faster than while. ... Both statements translate to exactly one assembly ... Some compilers/translators will recognize this is an infinite loop ... Clearly, that will depend on the compiler, neh? ...
    (comp.lang.php)
  • Re: what does two semicolns ;; do
    ... loops like: ... AIR foris slightly more efficient/faster than while. ... Both statements translate to exactly one assembly ...
    (comp.lang.php)
  • Re: Rules for "colon matching" in array operations
    ... < "scalarization pass inside of the compiler". ... Similarly, Andy talks about loops, but not ... Any routine using ENTRY compiles as one function ...
    (comp.lang.fortran)
  • Re: Support for optimization for dual core proc in C++
    ... Does the C++ in VS2005 allow optimization to parallelize and vectorize ... automatically like the product IntelC++ Compiler Version 10.0 does? ... restructures and optimizes loops to ensure that auto-vectorization, ...
    (microsoft.public.vc.language)
  • Re: Why is C# 450% slower than C++ on nested loops ??
    ... A nested loop written the way it is in the benchmark is measuring nothing but a compiler's ability to optimize nested loops that do more or less nothing. ... C# compiler generates such code, and the C++/CLI compiler is able to do so. ... It is reported that 2005 does a much better job of optimization of .NET code, yet, only with the C++, not the C# compiler. ...
    (microsoft.public.dotnet.languages.csharp)