Just across the hall from m// is s/// ...

Considering the semantics of m// and especially s/// at the user
level, we'll probably[*] want to take snapshots of dynamic strings
(think P5's "FETCH" or overload '""'), and apply all the pattern
operations to that snapshot.  *However*, in the usual case of applying
the pattern to a simple string, we want to avoid the overhead of
making a copy.  This may imply an API requirement.

For Topaz, Scalar's interface included a function that would basically
open the Scalar's hood, giving you a Buffer you could manipulate; then
when you were done working with the Buffer, its modifications (if any)
were propagated back down into the Scalar.  In the case of a simple
string, the Buffer in question was the actual guts of the string, so
the "propagation" was a nop; for magical Scalars, the Buffer was a
mortal result of a FETCH-analogue, and after the Buffer was done being
manipulated it was STORE-analogued back into the Scalar and destroyed.

Now Parrot could just punt on this by doing all the logic of
snapshotting and copying as part of the implementation of the
language-level feature, not down at the byte code.  But it's hard.
>From the outside of a PMC, how can you reasonable ask the question
"are you a basic string"?  Does that question always *have* an answer?
So we might think of "open up and say 'aaaah'" as a string feature
necessary for efficient regex work with minimal copying.

[*] Unless it's a _feature_ that given tied $a,
       ($a = "aaa") =~ s/a/b/g
    would call STORE four times ("aaa", "baa", "bba", "bbb").
-- 
Chip Salzenberg         - a.k.a. -        <[EMAIL PROTECTED]>
  "Persistence in one opinion has never been considered
  a merit in political leaders." --Marcus Tullius Cicero

Reply via email to