Open leonerd opened 3 years ago
A similar issue applies to (SV*)NULL
, which is represented as bless( do{\(my $o = 0)}, 'B::SPECIAL' )
. But I'm not sure if there are any APIs where that causes clunkiness similar to (OP*)NULL
in the original report.
One problem with having B::NULL
objects boolify to false is that they are also used for undefined scalar variables (but &PL_sv_undef
is another B::SPECIAL
):
2> B::svref_2object(\undef)
$res[0] = bless( do{\(my $o = 1)}, 'B::SPECIAL' )
3> my $undef
$res[1] = undef
4> B::svref_2object(\$undef)
$res[2] = bless( do{\(my $o = '94761693423424')}, 'B::NULL' )
In C code it's common to walk the child ops of a given optree node with code such as:
The sibling list is terminated by a node having
OpSIBLING == NULL
.At the Perl level when walking the optree with B, it represents a NULL pointer not with a Perlish
undef
but with a reference to aB::NULL
object (for reasons I do not follow). This object class ought to have a boolification overload making it appear false, so you could write the same code shape in Perl. It currently does not, meaning you have to