develooper Front page | perl.perl5.porters | Postings from October 2003

Re: RFC: changing behavior of defined() and exists()

Thread Previous | Thread Next
October 9, 2003 10:54
Re: RFC: changing behavior of defined() and exists()
Message ID:
>>>>> "Roy" == Roy Johnson <> writes:

Roy> defined() should evaluate its arguments in a context [I'm using this
Roy> term generically] wherein only undef is false. The normal usage of
Roy> defined() is unchanged: if you give it an undef value, it returns false,
Roy> otherwise, it returns true. However, if you give it a complex Boolean
Roy> argument, all of the logical operators recognize undef as false, and
Roy> everything else as true, and logical operators yield undef instead of
Roy> normal-perl-false.

Roy> Examples:
Roy>     defined($v = a() || b())   ## equivalent to $v = a() // b();
Roy>     defined($v ||= a())        ## equivalent to $v //= a();
Roy>     defined($v = \( $a && $b && $c && 'full'))

How far down would it reach?  Is it merely lexical, or is it dynamic?
That is, if I call a subroutine within that "change false to mean
only undef" scope, does the subroutine inherit the modified falseness?

I don't like creating new "action at a distance" settings.

Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<> <URL:>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See for onsite and open-enrollment Perl training!

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About