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 <[EMAIL PROTECTED]> 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 [EMAIL PROTECTED] have teddy bears and even teddy bears get drunk