lua-users home
lua-l archive

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

On Dec 18, 2011, at 14:22 , Rebel Neurofog wrote:

>> 4)  Add the convenience construt of   x += 123  (and other similar
>> operators)
> I would hate Lua for that since there's no such semantics in Lua.
> And syntax have to reflex semantics.
> In Python you may write str1 += "Something else\n" and
> wonder "Why the hell the script is so terribly slow?"
> '+=' is supposed to mean addition to existing memory block.
> But Python is similar to Lua about that: it constructs a new string.
> So Python isn't honest with me. I hope Lua won't ever be like that.

No, "a += b" simply means "a = a + b." That's it. So if "a + b" is slow, "a += b" is also going to be slow. If anything, Python's implementation is wrong because it *doesn't* strictly enforce that relationship, by providing special methods for += and the like. An "append" operation would be something more like Ruby's <<.

Matthew Frazier