[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Just a small request
- From: Flemming Madsen <lua@...>
- Date: Sat, 27 Jan 2007 11:47:38 +0100
Unfortunately the "official" continue patch from lua-wiki PowerPatches
(http://lua-users.org/wiki/LuaPowerPatches) is a little bad.
Specifically "continue" in "while" will not work, and also, will cause
errors in any while loop when executed from luac binary code
(sanity check finds jumps to a negative PC index).
Instead use the modified continue patch from BLua (http://blua.leet.cz/)
where this is fixed (function whilestat() in lparser.c).
Maybe either the PowerPatches page, or the patch itself should be updated?
/Flemming
On Thursday 25 January 2007 15:19, Andrew Wilson wrote:
> Hi Hugo,
>
> Here are a few references to previous discussions about a continue
> statement, seems people work around it or use tail recusion.
>
> http://lua-users.org/lists/lua-l/2005-09/msg00527.html
> http://lua-users.org/lists/lua-l/2003-06/msg00454.html
>
> Some customization too, have been made to add continue to lua...
> http://lua-users.org/lists/lua-l/2003-06/msg00306.html
>
> Regards
> Andrew
>
> On 1/24/07, Hugo Etchegoyen <hetchegoyen@hasar.com> wrote:
> > I have been working with Lua for only a few weeks, and I like the
> > language a lot. It offers a wonderful combination of size, speed,
> > simplicity, ease of learning and openness so that anybody can extend it
> > and tweak it to taste.
> >
> > But being a seasoned C/C++ programmer, there is only one thing I miss a
> > lot: a continue statement! Please, please, I know that people asking for
> > new features to be added to a language usually annoy its designers, and
> > generally for good reason. But I honestly think this would be a great
> > addition which would cost practically nothing and would benefit the
> > language and make it more coherent.
> >
> > Pascal was a coherent language: it religiously avoided anything that
> > could break the structured flow of control, so it did not have returns,
> > continues or breaks. It did not even have elseif! That is why most Pascal
> > programs are unreadable when they have more than two or three levels of
> > nested ifs and they tend to overflow the right margin unless programmers
> > use ugly and confusing indentation tricks.
> >
> > Clearly Lua is more like C, since it has return and break. But the
> > absence of continue complicates the body of loops. Consider this loop,
> > for example:
> >
> > for i = 1 to somevalue do
> > if some_condition then
> > ...
> > ...
> > ...
> > end
> > end
> >
> > Wouldn't this be nicer?
> >
> > for i = 1 to somevalue do
> > if not some_condition(i) then continue end
> > ...
> > ...
> > ...
> > end
> >
> > I know it's a matter of taste, but also of coherence. IMO Pascal was
> > coherent (but ugly) and Lua is beautiful but still lacks this last touch.
> >
> > Regards,
> > Hugo Etchegoyen