lua-users home
lua-l archive

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


Hi!

2012/11/28 Rob Kendrick <rjek@rjek.com>
>
> On Wed, Nov 28, 2012 at 05:17:28PM +0100, Matthias Kluwe wrote:

> > I played around trying to create a small DSL and stumbled upon an
> > unexpected behaviour. This is a small example:
> >
> > local function f()
> >     return setmetatable( {}, {
> >         __div = function( t, arg )
> >             print( arg )
> >         end } )
> > end
> >
> > f{} / 'a'
>
> That's because this is an expression, not a statement.  It doesn't work
> as f() / 42, either.  You need to specify where to put the result, or
> use it in a flow control structure.

Ah, yes, thank you. My thinking was still in C++-mode.

Regards,
Matthias