Sam Phillips <[EMAIL PROTECTED]> wrote: > Problem: > 1) To create an efficient implementation of Basil I'll need a big > PerlArray that is formed by expressions that create PerlStrings or more > PerlArrays.
How big is "big"? > So my main question is this: Are PerlArrays and PerlStrings an efficient > way to go with this? - how much copying goes on within a string > concatenation? There ar basically 2 forms of concat, one inplace and the 2nd creating a new string. The former is much more efficient the more you are appending small items to the first string. > ... Iterator? Iteration doesn't involve any copying. > ... etc ( ie does using COW prevent a deep copy > every time I make a concatenation). COW doesn't help in the case of concat. COW is mainly useful for extracting substrings. > I tried to make sense of PerlString concatenation and they seem to use > string_concat which in turn has two mem_sys_memcopys doing the actual > concatenation. Well, that depends. Inplace needs one only. > 2) If concat isn't the way forward then push probably is (I could just > hand back a tree and iterator (as a closure err do I mean continuation?) > to the calling function). I take it there are no hidden caveats in using > push on a PerlArray? Push is fine. > 3) I take it a proper iterator is far more efficient than a loop with a > shift in it? Yep. > 4) why doesn't '.' work on a PerlString in IMC? :-) It works - at least partially - inplcace is missing ;) $ cat c.pir .sub main $P0 = new PerlString $P1 = new PerlString $P2 = new PerlString $P0 = "a" $P1 = "b" $P2 = $P0 . $P1 # note the space before the dot print_item $P2 # $P0 .= $P1 # print_item $P0 print_newline end .end $ parrot c.pir ab > 5) I guess the way-forward for the future is a custom class of very-lazy > string-lists that can be concatenated, split, iterated, searched, sorted > etc You might have a look at "cord" which can be found e.g. in the gcc sources under the boehm-gc subdirectory. > Sambeau leo