First of all, you sent us this already.  :^)

Jeff 'japhy' Pinyan:
# I'm writing a simple language to embody the concept of
# copy-on-write, and
# so that I can learn how to implement it.  The language is
# called COW and
# it's at
#
#   http://japhy.perlmonk.org/COW/
#
# Ben Tilly suggested I contact the Perl6 Internals folk and
# let you know
# that this is an important feature that we should try to
# incorporate into
# Perl 6.

Don't worry, CoW is going in--Dan's been raving about it since the
beginning.  :^)

....
# So what's copy-on-write?  Basically, it's the use of a
# pointer until that
# use becomes unsafe.
....
# And that's that.  The language will take me a while to
# develop and all,
# but I'm interested in helping out as much as I can to integrate COW in
# Perl 6 -- it'll be a good idea, I feel.

Internals hackers:  Implementation-wise, I'm thinking we have a wrapper
PMC and vtable, with the original PMC in SELF->data and some metadata in
SELF->cache.struct_val; get operations just call the equivalent op in
the wrapee's vtable, while set operations tell all the dependencies to
copy their data, replace the wrapper with the wrapee, and call through
the new vtable.

(Japhy: that probably sounds like gibberish to you, but it's really
internals-speak.  :^)  Perl 6 doesn't have magic.  Instead, each PMC
(the data structure behind all variables, scalar or plural) has a table
of operations (called a vtable) attached to it; for example, there's a
bunch for get_integer (like get_integer_same and get_integer_bigint), a
bunch for math operations, etc.  Magical stuff is implemented by
swapping out the vtable.)

Only problems I see are:
        -At least for the substring example, we're talking about mucking with a
STRING's internals to get one to point into another's buffer, which is
generally a Bad Thing.  (Especially if there's some sort of start marker
on the string, like the UTF-16 BOM...)
        -GC might be a problem too--will it detect that the memory is still in
use, even if the pointer to it is pointing into the middle of the memory
instead of the start?  Maybe STRINGs should have a separate field for
the start of the actual string.

--Brent Dax
[EMAIL PROTECTED]
Configure pumpking for Perl 6

"Nothing important happened today."
    --George III of England's diary entry for 4-Jul-1776

Reply via email to