Re: What else?

Arthur Chance (Arthur.Chance@Smallworld.co.uk)
Wed, 26 Jan 94 12:14:24 GMT

Guido says:
> Stoffel Erasmus writes:
> > This brings one to the question whether {else} is the best keyword
> > to use with {for} and {while} loops. Is it not perhaps a case of false
> > economy to `overload' this keyword? I suspect that {end} might be a
> > better alternative here. One of the other alternatives might be
> > {finally} (as in the {try} statement), but it might be a bit too long.
>
> Well, it seemed a nice idea at the time...

:-)

> I personally think that the optional else clause on loops is so rarely
> used that it's better to remove it altogether, making the language
> smaller and removing one possible cause for confusion -- since no
> other language has this, one always has to explain exactly when it is
> executed and when not.

My company uses a customisation language (called Magik) for its GIS
that is *very* similar to Python in many ways. (A great example of
parallel evolution - we've only just come across Python, but it appears
Magik and Python were designed and implemented around the same
time, and reading the Python documents last weekend I found myself
amazed at how similar the designs are, given the different target
audiences we have.) Magik uses `finally' to introduce code to be
executed on loop exhaustion, and that feature is very rarely used. I
can think of about two examples in ~200 Klines of code.

> On the other hand, it doesn't hurt much, and some code will
> undoubtedly be broken and have to be rewritten in a more clumsy
> manner. I might even try to patent it :-)

That was exactly my feeling. When you need it, it's preferable to
kludgey code with flags. (I would arm wrestle you for the patent,
but I think the Zetalisp hackers might claim prior art. :-)