lua-users home
lua-l archive

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

the standard way to do this is:

> = 5-3
> function two() return 2 end
> =two()

Is that too "special" ?

probably can't automatically prepend an equal, as this breaks function definitions.

On 6/21/06, Sam Roberts <> wrote:

I have a console, and I want people to be able to enter lua expressions
in, and see the results without having to do anything "special".

Should I just take their input, and put a "return( " before it and a ")"
after it? This seems a little hackish... is it the best way? What I
really want is the _expression_ to not have its return stack discarded.

% lua -i
> function two() return 2 end
> two()
> return two()
> return( two() )
> return( two() + 4 )
> return( {"a", "b"} )
table: 0x8068b40

I'll have to implement __tostring for tables, I guess.