lua-users home
lua-l archive

Re: unexpected syntax error

[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

AltStyle によって変換されたページ (->オリジナル) /