lua-users home
lua-l archive

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


Peter Prade wrote:
> Subject: AW: Proper tail recursion
> Why change the language when you can already do the equivalent to tail
> recursions?
> just have the function return the function it would like to call as tail
> call.
> the only additional thing you need is a "main" function that does 
> the actual
> calling.

Excellent, Lua never fails to amaze me!
I will keep this technique for future use...

-----

John Belmonte wrote:
> Subject: Re: Making Lua lexically scoped (was: Re: Proper tail recursion)
> I don't agree about the "far more" part... if Lua had full 
> lexcial scoping,
> my existing programs would immediately benefit as I could remove all those
> ugly manual closures I build with tables.  Newcomers to Lua 
> wouldn't have to
> struggle with the mystery of upvalues.

Yes! I couldn't agree more. Upvalues were pure mystery to me, until I read
Roberto's book which explain them clearly. But they are still ugly and
unintuitive. This trick of using a table to allow an upvalue to be writable.
Shesh... :-)

-----

Roberto Ierusalimschy wrote:
> Subject: Re: The 4.1-alpha manual 
> > Frankly, I don't see much use of this format too... But perhaps 
> there is a
> > strong demand for it (reading config files? CSV/TSV?).
> 
> You mean the "*u"? Some uses are
> - lines ;-)
> - paragraphs ("*u\n\n")
> - e-mail messages ("*u\nFrom ")
> - mime parts (until boundary)
> - XML parts?? (read("*u<", "*u>")) (I am not sure this is enough...)
> - Lua functions, if you follow a reasonable identation ("*u\nend")

You cleverly included some examples embedding \n, to show that *l isn't
enough... There is still the *a + strfind argument, but again we may need to
process MB of data on a small system.
A strong point of Lua is its capability to manipulate binary data (including
zero bytes) as plain strings. I like it.
BTW, I expected format %q to quote also control characters, but they are
kept as is. I suppose it is by design. I know, I can do a gsub to do this. I
begin to grow familiarity with these regular expressions. They are quite nice
and powerful, even if some features are missing (alternation if I recall
correctly) and other need workarounds (the use of strrep).

Regards.

-- 
--._.·´¯`·._.·´¯`·._.·´¯`·._.·´¯`·._.·´¯`·._.·´¯`·._.--
Philippe Lhoste (Paris -- France)
Professional programmer and amateur artist
http://jove.prohosting.com/~philho/
--´¯`·._.·´¯`·._.·´¯`·._.·´¯`·._.·´¯`·._.·´¯`·._.·´¯`--

Sent through GMX FreeMail - http://www.gmx.net