Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

Journal of jjore (6662)

Thursday April 23, 2009
10:00 AM

Cursing perl 5

[ #38856 ]

I can't create a nil-class object. Argh! I am utterly prevented from doing a complete proxy/spy in Devel::Spy because of this. I can "fix" all use of defined() just like UNIVERSAL::ref but I can't fix all the uses of SvOK in C or XS code.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • Since Perl doesn't even have "nil", wtf are you talking about?
    --
    • Randal L. Schwartz
    • Stonehenge
    • I would assume creating an object that looks under casual inspection like [undef], but can support lots of methods, generally by returning itself. Which is to say an object that works like nil does in Ruby.

      This kind of object is surprisingly useful, but is impossible to create in Perl. You can almost get there, see Class::Null on CPAN. But not quite because override doesn't let you override defined.

      I'm guessing that jjore tried to resort to deeper hackery to get it, and discovered the hard way why overri

      • No, I already know I can replace the global PL_sv_undef with my own object, I can also override defined() everywhere in perl code. What I can't do is override all the XS which never calls defined() but rather more direct things like the C macro SvOK(sv).

        I would like to treat undef/nil as an instance of a NilClass but... impossible. Literally impossible.