VINE

On 12/13/06, Nicholas Clark <[EMAIL PROTECTED]> wrote:

For the effort to implement a Pugs backend to run Perl 6 on Perl 5, one
part that was looking tricky was how to make read only aliases of
read-write values. Data::Bind fakes the functionality with magic, but I
think that it's going to have limitations with corner cases.

The better solution appears to be to add a type to the core, akin to
references (SvRV) which acts as an automatic alias type.

Since 5.000 there have been 16 internal types in Perl, which feels like a
nicer number to keep than go to 17.

With change 29544 I've finished moving things around to abolish the need
for the PVBM type, probably the least used of any of the internal types.
Its functionality, storing tables for fast Boyer-Moore string scanning,
can be achieved by using PVGV after a bit of rearranging of flags and
structures.

So to keep at the nice number of 16, there is a placeholder for a new
type,
tentatively named BIND, for 6-on-5 aliasing. It's all yours, 6-on-5
hackers.

I'm not exactly sure what is needed for 6-on-5, beyond read only aliases
to read-write values, but I think that implementing a workable version of
that should be fairly straightforward. Probably something like:

a: Make all data reading functions, as their first action, check if they
have
   a BIND, and if so dereference it immediately.
   Functions like sv_2iv_flags, sv_2uv_flags etc
b: Make all data writing functions, as their first action, check if they
have
   a BIND. If it's not read only, dereference it immediately.
   Otherwise, leave it be, and it will hit that function's readonly check
   for the correct error. (Look for PL_no_modify, which holds the string
   "Modification of a read-only value attempted"
c: Ensure that the macro SvOK() chases the dereference.
   (As it's likely that the dereference itself won't have any of the SV
flags
    set that mark it as "true"


Although some niggling sense of doubt tells me that it will get fun before
it gets pretty.

Suggestions for a better name for BIND welcome. 4 letters or fewer.

Nicholas Clark

PS blead source is at rsync://public.activestate.com/perl-current/




--
Outside the mind, there is no Lotus Sutra..& outside the Lotus Sutra, there
is no mind...

(Hakuin)

antiparanoid.blogspot.com

Reply via email to