> Perhaps I'm misunderstanding Dan's meaning when he talks of invalidating
> method handles. In Perl5:
>
> package Foo;
> sub bar { print "hello world\n" }
> package main;
> my $cref = Foo->can('bar');
> undef *Foo::bar;
> Foo->$cref();
> Foo->bar();
> 1;
>
> would result in:
>
> hello world
> Can't locate object method "bar" via package "Foo" (perhaps you forgot
> to load "
> Foo"?) at [...] line 7.
>
> As you can see, this is something you can do this in Perl5. And as Perl6
> is supposed to be able to run Perl5... I'd think this'd be something
> parrot'd be required to support.

Hrrm.  I didn't know that case worked :o
I guess then that we'd be returning a code-object and calling the (nifty
new) compile opcode on it when we wanted to actually run it ... from what
I understood of Dan's last reply, though, we're getting "yes/no" and this
entire subtree got pruned :o

I guess we'd be, effectively, looking at ref counters (like with memptrs
and GC), so we can say "oh, we deleted that, but I have this reference, so
I'll invalidate the real call, but leave it there so the ref works",
effectively like hard links on unix, i guess ...

Would that work as an option to resolve it?  I don't know the memory or
data-store values (especially not of objects that are still just words :o)
but would it be possible to keep a refcount for the items, set at 1 (b/c
it's defined :) and then if someone does a can() we increment it until the
$val that can() went into either gets undef'd, descoped, or otherwise
loses it's reference?  (those two are static events, I think, and $var
could just tell it's ref that it's going away, quit counting me ... )

random mumblings that I don't really understand how they'd work in parrot:

If we have a FPtr PMC, and we provide it as a return to can(), after
incrementing the internal refcount ...

Then on an "undef *Foo::bar;" it invalidates the name in the PMC (and
Foo's meth tables?) and decreases it's refcount ...

Then set whatever kinds of traps (I guess they'd be compiler level) so
that whenever the value of the $var that took the result of can() is
changed, it decrements the refcount ... I think that's compiler level, so
it just takes longer  to compile, while it tosses in the extra opcodes for
decrements ...

and then if the refcount == 0 we just mark it for GC and forget about it
entirely ...

Like i said, no idea how all that ACTUALLY works out in parrot, though :o

--attriel


Reply via email to