Re: Loop
- Posted by CChris <christian.cuvier at agriculture.gouv.fr> Jun 01, 2007
- 780 views
Dan-Åke Engqvist wrote: > > I would like to suggest that Euphoria should have loop-end loop. > It looks more clear and possibly runs a little faster > (since it doesn't has to check if 1 is true or not). > > Instead of: > while 1 do > do_something > if something_is_true then exit end if > end while > > It should be this: > loop > do_something > if something_is_true then exit end if > end loop > > Dan-Åke Engqvist This optimisation is already being performed. If you look at the emit.e file in the source directory, you'll see that, when the conditional clause of a while statement is a nonzero constant, the code which checks the condition on each loop iteration is not generated, hence is not executed. This optimisation is mentioned in the release notes. As to whether "while 1 do" is clearer than "loop"... The latter is shorter, so it is better. This is typically the sort of things a preprocessor would do, but there is no official preprocessor for Eu. There are a few in the archive. CChris