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.
Re:what is "nil" in Perl?
btilly on 2009-04-24T07:06:55
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 override made that omission.
Re:what is "nil" in Perl?
jjore on 2009-04-24T14:23:30
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.