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
Stories, comments, journals, and other submissions on use Perl; are Copyright 1998-2006, their respective owners.
what is "nil" in Perl? (Score:2)
Reply to This
Re: (Score:1)
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
Re: (Score:1)
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.