Re: what does two semicolns ';;' do



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.


--
Jim Pennino

Remove .spam.sux to reply.
.



Relevant Pages

  • Re: what does two semicolns ;; do
    ... loops like: ... AIR foris slightly more efficient/faster than while. ... Both statements translate to exactly one assembly ... Since we're presuming we don't know how clever the compiler is ...
    (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: Question converting function from c to matlab
    ... to do some debugging, but I am not very good with c-coding. ... The for loops just use;; as their index, ... How do I translate this? ...
    (comp.soft-sys.matlab)
  • Question converting function from c to matlab
    ... to do some debugging, but I am not very good with c-coding. ... The for loops just use;; as their index, ... How do I translate this? ...
    (comp.soft-sys.matlab)
  • Re: what does two semicolns ;; do
    ... Both statements can easily translate to exactly one assembly instruction: ... Some compilers/translators will recognize this is an infinite loop ...
    (comp.lang.php)