1. Looping construct's(was Re: registration and requests)

I proly missed it but is the some form of a goto statement??

Grape


>Date:         Mon, 15 Feb 1999 16:58:05 -0500
>Reply-To:     Euphoria Programming for MS-DOS
<EUPHORIA at LISTSERV.MUOHIO.EDU>
>From:         Robert Craig <rds at ATTCANADA.NET>
>Subject:      Re: registration and requests
>To:           EUPHORIA at LISTSERV.MUOHIO.EDU
>
>Gabriel Boehme writes:
>> Doesn't the interpreter have
>> to check that "while 1" condition each time through the loop?
>> Not very speed efficient.
>
>"while 1 do" is optimized away at compile time.
>(Actually, any non-zero constant will be optimized.)
>No internal code is emitted.
>The "end while" will jump unconditionally back to the
>first statement in the while loop. No test is ever
>performed at run-time.
>
>With Euphoria 2.1 it's even better. Consider:
>
>  while 1 do
>        a += 1
>        if a > b then
>              -- bunch of statements
>        end if
>  end while
>
>With "branch straightening", when a <= b the internal form
>code for the if-statement will jump *directly* back to "a += 1",
>without executing the unconditional branch at "end while".
>
>I have to admit that "while 1 do" seems like an awkward
>way to introduce an infinite loop (Euphoria is not alone in this.)
>However I don't want to introduce a third looping construct. In the
very
>early days, pre-1.0, I resisted adding the for-loop statement -
>everything was done with while-loops up to that time.
>
>John Bown writes (regarding minimalism):
>> why were the += / -= operators added ? They
>> certainly weren't *needed*.
>
>That's a good point. I resisted adding these assignment operators
>for a long time, on the basis of minimalism. Finally a few months
>ago I succumbed, after typing statements like:
>
>  galaxy[row][column][otype] = galaxy[row][column][otype] + 1
>
>in many places in Language War.
>
>What would the *ultimate* minimal language look like?
>
>Theoretically the following language, consisting of 4
>statements, will let you compute any mathematical
>function that you can compute in Euphoria, C++, or any
>other programming language. (Note that I/O is not considered,
>just computation.)
>
>1.   var = 0
>2.   var = var + 1
>3.   goto label
>4.   loop var times ... end loop
>
>where any statement can have a label, and be the target of a goto.
>You can introduce as many vars as you want, without declaring them.
>
>Want to add 3 to x?
>     x = x + 1
>     x = x + 1
>     x = x + 1
>
>Want to assign y to x?
>    x = 0
>    loop y times
>          x = x + 1
>    end loop
>
>Want to subtract? multiply? divide? remainder? You can do
>them all with loops and adding 1.
>
>Regards,
>     Rob Craig
>     Rapid Deployment Software
>     http://members.aol.com/FilesEu/


______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com

new topic     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu