lua-users home
lua-l archive

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

Can I know why there is no such operators as ++ or += (or similarly others like string concatenation) in Lua?

I think the best argument for not including compound assignments in Lua is that they're an awkward companion for multi-value returns.  Specifically, we need sensible rules governing how the compiler should handle the following:

I've played around with a couple different semantics -- and all of them feel like kludgy additions to an otherwise very elegant language.

But if you're willing to give up a bit of elegance, there's a couple different lua patches posted that add compound assignments to the language, including one by me.  See: and


PS: I've been meaning to update my own patch -- the multi-value semantics in the posted version are uglier than they need to be. So if you're interested in trying it, let me know.