lua-users home
lua-l archive

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


Well, that is what I do now as a kind of kludge. But that is not exactly
right, unless lua can handle constructs like:

return if foo then
return a
else
return b
end

But surely, if this is a feature that is helpful, we can do better...

Eric

> -----Original Message-----
> From: owner-lua-l@tecgraf.puc-rio.br
> [mailto:owner-lua-l@tecgraf.puc-rio.br]On Behalf Of Steve Dekorte
> Sent: Tuesday, May 22, 2001 2:23 PM
> To: Multiple recipients of list
> Subject: Re: Making vars local by default
>
>
>
> Eric Ries wrote:
> > I am curious if it would be worthwhile to implement a perl-style eval()
> > for
> > executing lua code. Lua's dostring() is very close, but eval() has the
> > added
> > advantage of automatically returning the last statement executed. So for
> > instance eval( "10" ) is equivalent to dostring( "return 10" )
>
> so why not add just this line to your code?:
>
> function eval(s) return dostring("return "..s) end
>
> Steve