lua-users home
lua-l archive

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


<c8fb785d4d.wra1th@wra1th.plus.com> 
 <200504200648.30842.javier@guerrag.com>
In-Reply-To: <200504200648.30842.javier@guerrag.com>
X-Organization: Home
User-Agent: Messenger-Pro/1.00c (MsgServe/1.00a) (RISC-OS/5.08) POPstar/2.05
Reply-To: lua@bazar2.conectiva.com.br
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii

In message <200504200648.30842.javier@guerrag.com> 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 
> algorithm.
> 
> 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 
> old?

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 (gavin@wra1th.plus.com)
Home page: http://www.wra1th.plus.com/