lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


--- Peter Wang <tjaden@alphalink.com.au> wrote:
> Oscar Lazzarino <osk@cclinf.polito.it> wrote:
> > I don't really agree. You just have to use some self-discipline. And if
> > you don't like the costruct, you're not forced to use it... But you
> > can't deny that 
> > 
> >  while ( X = read() )
> >  do
> >   print ( X )
> >  end
> > 
> > is by far nicer and CLEARER than
> > 
> >  X = read()
> >  while X
> >  do
> >   print ( X )
> >   X = read()
> >  end
> 
> I would dispute "clearer".  I prefer the following construct to both
> of the above (though I often use the first one in C).
> 
> while 1 do
> 	X = read()
> 	if not X then break end
> 	print ( X )
> end	

Some people considering breaking out of a loop like that to be evil; just as
bad as using a goto.  It's six of one, half a dozen of the other. In this case,
your preferred practice is somebody else's taboo.

Of the three examples above, I find the first to be the clearest. But that's
probably just the old C programmer in me talking. ;)
 
> Remember also that Lua is designed to cater for non-programmers, who are very
> likely to type `=' instead of `=='.

Lua should have had a different operator for assignment anyway (IMO). Decades
of suffering C programmers have already proven that this was a bad design
choice. Personally, I've always preferred Pascal's assignment operator.

Cheers,
Eric


__________________________________________________
Do You Yahoo!?
Get email at your own domain with Yahoo! Mail. 
http://personal.mail.yahoo.com/?.refer=text