Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

__find_method Overrideable From PASM/PIR?

6 views
Skip to first unread message

Chromatic

unread,
Apr 5, 2004, 12:12:36 AM4/5/04
to perl6-i...@perl.org
According to PDD15, defining a method called __find_method() in my PASM
or PIR would allow Perl 5 AUTOLOAD-like behavior.

I can override __get_string() -- and it's tested in t/pmc/delegate.t.
Is __find_method() workable yet? If not, how would I go about adding
it?

t/pmc/delegate.t looks like the right place for it, but I distrust that,
for example, the test for __get_string() actually tests what it should
test. I'd expect to need to define an entirely new class.

Of course, if I'm misunderstanding PDD15 altogether, that's cool too.

-- c

Leopold Toetsch

unread,
Apr 5, 2004, 3:26:15 AM4/5/04
to Chromatic, perl6-i...@perl.org
Chromatic <chro...@wgz.org> wrote:
> According to PDD15, defining a method called __find_method() in my PASM
> or PIR would allow Perl 5 AUTOLOAD-like behavior.

That's a cut'n'paste error in pdd15 - at least now. All vtable methods,
which are explicitely in ParrotClass/ParrotObject aren't overridable.
You might have a look at classes/parrotobject.c:

...
Parrot_delegate_clone,
Parrot_ParrotObject_find_method,
Parrot_delegate_get_integer,
Parrot_delegate_get_integer_keyed,
...

But there will be of course some AUTOLOAD scheme. And you can simulate
one with exceptions:

.sub _main
$P0 = newclass "A"
$I0 = find_type "A"
.local pmc obj
obj = new $I0
.local pmc exh
newsub exh, .Exception_Handler, _exh
set_eh exh
obj."meth"(42)
print "done\n"
end
.end

.sub _exh
print "exh\n"
print "exh - wanted '"
print S0
print "'\n"
$P0 = find_global "A", "__f42"
invoke $P0
.end

.namespace ["A"]

.sub __f42 method
print "42\n"
.end

$ parrot o.imc
exh - wanted 'meth'
42
done

leo

Dan Sugalski

unread,
Apr 6, 2004, 10:46:55 AM4/6/04
to l...@toetsch.at, Chromatic, perl6-i...@perl.org
At 9:26 AM +0200 4/5/04, Leopold Toetsch wrote:
>Chromatic <chro...@wgz.org> wrote:
>> According to PDD15, defining a method called __find_method() in my PASM
>> or PIR would allow Perl 5 AUTOLOAD-like behavior.
>
>That's a cut'n'paste error in pdd15 - at least now.

It needs fixing--the docs, that is, not the method. Making a custom
find_method is going to require a bit more thought, and it might well
need some other interesting stuff. (It ought not be inheritable, for
example, because then you'd need find_method to find find_method...)
--
Dan

--------------------------------------"it's like this"-------------------
Dan Sugalski even samurai
d...@sidhe.org have teddy bears and even
teddy bears get drunk

Chromatic

unread,
Apr 6, 2004, 12:38:23 PM4/6/04
to Dan Sugalski, perl6-i...@perl.org
On Tue, 2004-04-06 at 07:46, Dan Sugalski wrote:

> It needs fixing--the docs, that is, not the method. Making a custom
> find_method is going to require a bit more thought, and it might well
> need some other interesting stuff. (It ought not be inheritable, for
> example, because then you'd need find_method to find find_method...)

That's fine. I don't need it now -- Allison suggested a much simpler
scheme that works with what's implemented now.

-- c

0 new messages