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

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

Elizabeth Mattijsen
October 20, 2003 07:01
Re: [perl #24250] "return" required in some anonymous closures
Message ID:
At 14:57 +0100 10/20/03, Dave Mitchell wrote:
>On Mon, Oct 20, 2003 at 02:29:11PM +0200, Elizabeth Mattijsen wrote:
>  > Seriously, I haven't been able to find _any_ documentation on this
>>  feature.  It definitely is not mentioned in the 5.8.0 perldelta (or
>>  it is described without the terms "constant" or "generator").
>>  If this _is_ a new feature of 5.8.0, maybe it should be at least
>>  documented in the 5.8.2 perldelta?  And possible somewhere else.
>>  Suggestions for locations where this should be documented?  I'll
>>  write up a description and submit a patch then.
>I think the best place would be in perlsub.pod in
>=head2 Constant Functions

Ok, I'll do that but first:

>Personally I think its a confusing feature, but it appears to be used
>in lib/ - presumably as a cheap way of creating the const subs
>as needed. C<use constant foo => 1> gets implemented like
>     { my ($name, $val) = @_; *$name = sub(){$val} }
>Anyone feel like deprecating it ;-)

Well, I guess Dominus feels like me, that it is catching people by surprise.

I think this would call for a compile-time CODE attribute ": constant":

{my ($name, $val) = @_; *$name = sub : constant{$val}

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