lua-users home
lua-l archive

Lua function syntax sugar for a digit started function name?

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


Lua 5.1.4

For example:

bar ={} 
bar.name ='test' 
bar['123.com']=function(self) print(self.name)end

I can't call the method like below:

bar:['123.com']() 
stdin:1:'<name>' expected near '['

Althought below works:

bar['123.com'](bar)

But I this is somehow ugly. Is there a syntax sugar for this situation?

Or if it really cannot do it, will Lua team add this syntax in future?

Or Lua team did this intentionally?


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