[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Proposal: improvement of string.gsub()
- From: Gavin Wraith <gavin@...>
- Date: Wed, 20 Apr 2005 13:16:44 +0100
User-Agent: Messenger-Pro/1.00c (MsgServe/1.00a) (RISC-OS/5.08) POPstar/2.05
Content-Type: text/plain; charset=us-ascii
In message <firstname.lastname@example.org> you wrote:
> On Monday 18 April 2005 4:55 am, Gavin Wraith wrote:
> > Unfortunately this breaks referential transparency - a bad idea.
> > The usual remedy for string manipulation is never to concatenate
> > strings, but instead to use "stringles" - lists whose components
> a similar solution is to change the underlying language implementation to
> something more appropriate. the STL includes a 'rope' template.
> the idea is > similar to your 'stringles': a tree of strings.
> the main difference is that
> the language itself manages them.
> on a related issue: in LTN9, there's the advice not to build big strings by
> accumulation, instead it uses a stack and merges it down in a binary
> i ask: what about building an array with table.insert() and get the final
> string with table.concat()? isn't that faster/easier? maybe LTN9 is too
If the final string is actually needed, that is clearly the way to go.
In practice, it very rarely is needed. Usually the rope/stringle (sorry
"stringle" was an extemporization) gets written out to a file. The point
is that ropes are very easy to program in Lua. I doubt whether managing
them at the C level gains one very much.
Gavin Wraith (email@example.com)
Home page: http://www.wra1th.plus.com/