While loop

Yves Jaradin yves.jaradin at uclouvain.be
Fri Jun 6 09:47:48 CEST 2008


Hi,

We at UCL would like to introduce a while loop construct in Mozart of 
the form:

while Expression do Statement end

This has already been discussed a lot on this mailing list (e.g. 
http://lists.gforge.info.ucl.ac.be/pipermail/mozart-hackers/2002/000244.html) 
but no consensus was reached at the time. Here are the (main) arguments:

PRO:
Easy to use
Easy to teach/learn
Much less awkward than "for while:"

CONS:
The for loop can provide equivalent behaviour
Yet another keyword

On the equivalent behaviour part, this is true but not unique at all. 
Lots of constructs are redundant in the language. The "if" can be 
completely replaced by "case", "local" by "(", etc. Essentially, this is 
what the language is about ; being multi-paradigm means that we can use 
the most natural way to express a program and not the single way in 
which it is possible to write it.

On the "yet another keyword" part, this is the only keyword addition 
which was asked in more than six years. This should make clear that the 
fear of keyword explosion (breaking lots of programs using them as 
unquoted atoms) is probably not justified. As for the programs that use 
while as an atom, the only one in the Mozart svn is ozmake which use it 
in only in the "for while:" construct, all cases being possible to 
replace with a simple while loop.

Comments are welcome.

Cheers,
Yves


More information about the mozart-hackers mailing list