lua-users home
lua-l archive

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




On Wednesday, September 10, 2014, Axel Kittenberger <axkibe@gmail.com> wrote:
The question should rather be, why do you need brackets for this?

I'd expect

'5':rep( 10 ).

to work. 

You need the parenthesis because

foo"bar":rep(5) will be translated to

(foo("bar")):rep(5)
 


On Wed, Sep 10, 2014 at 7:04 PM, Dirk Laurie <dirk.laurie@gmail.com> wrote:
2014-09-10 17:38 GMT+02:00 Robert McLay <mclay@tacc.utexas.edu>:
> Thanks all.  It is clear that this is safe to use.  At least until there is
> a good reason to remove support for it in later releases.
>
> I get that ("5",x,y) is going to return "5".  What I don't get is why then
> is:
>
>    s = '5':rep(4)
>
> does not work but
>
>    s = ('5'):rep(4)
>
> does.

prefixexp ::= var | functioncall | ‘(’ exp ‘)’

functioncall ::=  prefixexp args | prefixexp ‘:’ Name args

Since '5' is neither a variable nor a function call, it needs parentheses.