develooper Front page | perl.perl6.language | Postings from May 2001

Re: 1 until defined(getvalue()); return it;

Thread Previous | Thread Next
From:
David L. Nicol
Date:
May 30, 2001 12:58
Subject:
Re: 1 until defined(getvalue()); return it;
Message ID:
3B154FF3.31489819@kasey.umkc.edu
Buddha Buck wrote:

> Why is [...] better than
> 
> 1 until defined($foo=getvalue()); return $foo; 

small incremental improvement to [read|writ]ability

writability:

one less thing to write
one less variable name to have to remember not to collide with

readability:

keyword "it" means look at very recent code, instead of starting
at the top of the block and reading down to find what $foo
is (trivially solvable by reading backwards...)


when they're all calls to the same function it doesn't help, but
if they are possible return points from a long routine, it would
be nice to formalize the object-of-defined construction.

It would not be difficult to implement.  Would it?  the it.pm
module would export "it" as a function that returns whatever is
in $nicol::it::itstash and invoke a source filter that replaces
the last instance of exists or defined before an occurance of "it"
with an alternate implementation that sets the stash.


-- 
                      David Nicol 816.235.1187 dnicol@cstp.umkc.edu
                                                     # die smiling;


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