lua-users home
lua-l archive

Re: help with lua style and syntax

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


2012年10月23日 David Collier <myshkin@cix.co.uk>:
>
> Essentially I have come to like the ability of a C assignment to be used
> as a value - and if Lua could handle it, including multiple-value
> assignments - which are a great feature of Lua, some of my code would
> look a lot neater :-)
>
If you're willing
(a) to quote the target names
(b) to squint slightly so that `-` looks like `=`
you can do this:
> getmetatable"".__sub = function(a,b) _ENV[a]=b return b end
> b=('a'-6)*10
> =a,b
6	60
and therefore this:
 if ( 'passed' - myFunction( x , y , &z ) )
 && ( 'passed' - mySecondFunction( z, &q ) )
Multiple returns are harder: the only metamethod that can take
three or more arguments is `call`.

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