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

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

Thread Previous | Thread Next
From:
Johnson, Roy
Date:
October 17, 2003 09:34
Subject:
RE: RFC: changing behavior of defined() and exists()
Message ID:
162CD748CF8119438D558F0A96BDC59125CE9A@prw2kt82.corp.ercot.com
> From: Michael G Schwern [mailto:schwern@pobox.com] 
> Sent: Friday, October 17, 2003 10:22 AM

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

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
not
  worth doing. It was my hope that the prospect of having a context
without
  multiple false values would have some appeal.
there's the prospect of seeing whether all of a set of values are
defined:
    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().

Roy

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