lua-users home
lua-l archive

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


On Fri, Mar 23, 2012 at 11:05 AM, Luiz Henrique de Figueiredo
<lhf@tecgraf.puc-rio.br> wrote:
>> > Lua optimises expressions of that form into a single concatenate
>> > operation.
>>
>> As well as
>> for k = 1, 100 do s = s...k end
>> ?
>
> No, of course not. But it's pretty easy to write an implementation of ropes
> using tables and the appropriate concat and tostring metamethods.
>

I know Lua's supposed to be lean and mean and let most things get
implemented in script, but I can't help but think that Axel is right.
This is common enough (especially since a staple use of scripts is for
data handling) that I think it would be in Lua's best interests to
handle this internally. It'll make development more straightforward
and intuitive, instead of making a common operation be noticeably
inferior when implemented in the obvious way. There shouldn't need to
be unobvious idioms for it; that just raises the barrier to entry and
makes Lua seem slower (and therefore less attractive) to new users.

I mean, *I* know the table.append/.concat idiom for this operation,
but an internal rope-type implementation could provide efficiency that
even table methods couldn't.

/s/ Adam