Root-relative namespace keys
Patrick R. Michaud
pmichaud at pobox.com
Wed Jan 7 02:20:53 UTC 2009
On Tue, Jan 06, 2009 at 04:44:47PM -0800, Allison Randal wrote:
>> Similarly, to check if an object isa ['Foo';'Bar'] from that other
>> hll (and we don't already know that the ['Foo';'Bar'] class exists):
>>
>> $P99 = get_root_namespace ['hll';'Foo';'Bar']
>> if null $P99 goto not_isa
>> $I0 = isa $P0, $P99
>> goto done
>> not_isa:
>> $I0 = 0
>> done:
>
> If the other hll namespace doesn't exist, then we can guarantee that the
> given object isn't from that class. That is, passing in a null PMC to
> 'isa' should always return false. (Checking...) Okay, yes, a null PMC
> returns false for 'isa' so you could just do:
>
> $P99 = get_root_namespace ['hll';'Foo';'Bar']
> $I0 = isa $P0, $P99
When I try this in current trunk (r35084), I get:
$ cat x.pir
.sub 'main'
$P0 = box 3
$P99 = get_root_namespace ['parrot';'Foo';'Bar']
$I0 = isa $P0, $P99
say $I0
.end
$ ./parrot x.pir
Null PMC access in isa_pmc()
current instr.: 'main' pc 6 (x.pir:4)
$
More to the point, if the 'isa' opcode manages to accept a null PMC
in the way you describe (i.e., without throwing an exception), it
will be the *first* such opcode I've encountered that does so.
If we're going to change 'isa' to automatically return false when
given a null PMC as its last argument, then there are some other opcodes
where I'd like us to consider applying the same rule -- i.e., returning
false or something more graceful than throwing an exception.
> [...]
> I'll propose alternatives in a separate email.
I look forward to this.
Pm
More information about the parrot-dev
mailing list