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

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

Thread Previous | Thread Next
From:
merlyn
Date:
October 9, 2003 10:54
Subject:
Re: RFC: changing behavior of defined() and exists()
Message ID:
86ekxm1elk.fsf@blue.stonehenge.com
>>>>> "Roy" == Roy Johnson <rjohnson22@ercot.com> 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
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About