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

Re: [perl #24250] "return" required in some anonymous closures

From:
hv
Date:
October 21, 2003 06:07
Subject:
Re: [perl #24250] "return" required in some anonymous closures
Message ID:
200310211311.h9LDBW932619@zen.crypt.org
Dave Mitchell <davem@fdgroup.com> wrote:
:I provisonally propose the new syntax:
[...]
:ie roughly speaking
:
:    sub foo() : constant { $x + $y }
:
:is about equivalent to
:
:    sub foo() { $x + $y }
:    BEGIN {
:	my $val = foo();
:	no warnings 'redefine';
:	eval 'sub foo() { "' . $val . "}'
:    }

The biggest problem I see with that is this:
  future% perl -wle 'my $pi = 3; sub pi () : constant { $pi } print pi()'
  Use of uninitialized value in concatenation (.) or string at -e line 1.
  
  future%

I'm in at least two minds about how big a problem that actually is.

Hugo



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