[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Can someone sell Lua 5.2.0 to me please ?
- From: liam mail <liam.list@...>
- Date: Mon, 19 Dec 2011 00:20:15 +0100
On Sunday, 18 December 2011, Rebel Neurofog <firstname.lastname@example.org> wrote:
> On Mon, Dec 19, 2011 at 12:29 AM, Matthew Frazier
> <email@example.com> wrote:
>> On Dec 18, 2011, at 14:22 , Rebel Neurofog wrote:
>>>> 4) Add the convenience construt of x += 123 (and other similar
>>> 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
> I disagree. Although C++ isn't a language of my love it has great
> operator concept.
> operator+= increases value IN-PLACE. So you just can't += immutable
> (by design) object.
> Same thing with strings: you may optimize string growing by reserving 2^N bytes
> (where 2^(N -1) < real_size <= 2^N) on each reallocation.
> So API can and should give a programmer an idea about what's inside.
For anybody interested there was a composite operator patch  posted for 5.1 a few months ago.