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

[RfC] Testing for null

0 views
Skip to first unread message

Dan Sugalski

unread,
Dec 8, 2003, 10:03:00 AM12/8/03
to Melvin Smith, l...@toetsch.at, Juergen Boemmels, perl6-i...@perl.org
At 1:21 PM -0500 12/3/03, Melvin Smith wrote:
>We should have 1 recommended way for testing NULL registers.
>
>If we support get_bool() then lets make sure it works for REAL NULL
>pmc registers as well as PMCNULL.
>
>If not, code will appear to work correctly on a "safe" core
>but will seg fault on some other. Also, I see no reason not
>to use PMCNULL in all cores now.

Okay, lets do this:

Add an isnull branch op:

isnull Px, destination

Leave the Null PMC as something with every vtable entry pitching a
for. The Null PMC is the "this register/array entry/hash entry is
full of crap and you're lucky I'm not segfaulting, dammt!"
alternative to a real NULL pointer.

Add in an undef PMC. A subset of PerlUndef, with the automatic
morphing to other perl base types. It notes that we have an actual
PMC, but one with garbage contents. We should have an interpreter
flag that indicates what Undef should do when its contents are
accessed (Though I'm really tempted to have undef return actively
random data) more or less equivalent to perl's -w flag. (Which notes
whether undef quietly returns a value, throws a warning, or pitches a
fatal exception)

The two can be looked at as:

Null - the register/aggregate entry doesn't point to anything
Undef - the register/aggregate entry points to a PMC, but the PMC
isn't initialized

That'd seem to cover it, at least until the SQL folks pop up with
inquiries about SQL's NULL and three-value logic, but I'm still sick
so I think I'll hide from that for a while.

I can see having an isundef op equivalent to the isnull op. If
someone wants to make even a token argument for it, throw it in.


>Juergen Boemmels <boem...@physik.uni-kl.de> wrote:
>> Hi,
>
>> I'm curently playing around with open calls returning a PMCNULL
>> instead of a half valid IO-Object. But the main problem with that is
>> that there is currently no way for the byte-code to detect such a
>> case.
>
>C<defined> tests for PMCNULL too and is usable.
>
>> * A PMCNULL has false semantics. This may be done by letting
>> get_boolean return FALSE, or by adding a test to if_p_ic op:
>> if(!PMC_IS_NULL($1) && $1->vtable->get_boolean($1))
>
>Or the null.pmc gets a valid get_bool() vtable slot returning 0.
>OTOH when PMCNULL is a real NULL, this will fail then.
>
>> * Have a special op for this if_null and unless_null which exlusively
>> test for NULL.
>
>Probably better.
>
>> boe
>
>leo


--
Dan

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

Gordon Henriksen

unread,
Dec 8, 2003, 4:36:16 PM12/8/03
to Dan Sugalski, Melvin Smith, l...@toetsch.at, Juergen Boemmels, perl6-i...@perl.org
On Monday, December 8, 2003, at 10:03 , Dan Sugalski wrote:

> At 1:21 PM -0500 12/3/03, Melvin Smith wrote:
>> We should have 1 recommended way for testing NULL registers.
>>
>> If we support get_bool() then lets make sure it works for REAL NULL
>> pmc registers as well as PMCNULL.
>>
>> If not, code will appear to work correctly on a "safe" core
>> but will seg fault on some other. Also, I see no reason not
>> to use PMCNULL in all cores now.
>
> Okay, lets do this:
>
> Add an isnull branch op:
>
> isnull Px, destination

How about this to test if Px is really null?

null Py
eq_addr Px, Py

Gordon Henriksen
mali...@mac.com

Dan Sugalski

unread,
Dec 9, 2003, 11:35:57 AM12/9/03
to Gordon Henriksen, Melvin Smith, l...@toetsch.at, Juergen Boemmels, perl6-i...@perl.org

That involves explicitly doing things with PMCs we've just decared
are bogus. Seems a little backwards. :)

I think I'd prefer the check for explicit bogusness be a separate
opcode, that way it can also check for real NULLs.

Leopold Toetsch

unread,
Dec 10, 2003, 6:33:48 AM12/10/03
to Dan Sugalski, perl6-i...@perl.org
Dan Sugalski <d...@sidhe.org> wrote:
> Add an isnull branch op:

> isnull Px, destination

Done.

leo

0 new messages