lua-users home
lua-l archive

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


The question should rather be, why do you need brackets for this?

I'd expect

'5':rep( 10 ).

to work. 


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.