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

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

Thread Previous | Thread Next
Johnson, Roy
October 17, 2003 09:34
RE: RFC: changing behavior of defined() and exists()
Message ID:
> From: Michael G Schwern [] 
> Sent: Friday, October 17, 2003 10:22 AM

> I want to go straight to the heart of the problem.  Where's the use

Well, quite apart from the fact that I did say:
  If the only practical use anyone can see for it is the // niche, it is
  worth doing. It was my hope that the prospect of having a context
  multiple false values would have some appeal.
there's the prospect of seeing whether all of a set of values are
    if (defined($a && func($a))) {...

I didn't present it as a targeted solution, nor did I suggest that it
was a critically-needed enhancement. It is simply an elegant (in the
sense of DWIMming with no new syntax) extension of defined() that
addresses a common problem.

> 	defined($foo ||= "bar");
> [...] is nearly as involved as the current way to do it.

It avoids the repetition of the variable being tested, which is the
thing that makes the current way clunky. Keystroke economy is a
secondary consideration, not the primary one. In other uses, it would
avoid repetitive calls to defined().


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