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

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

From:
Rafael Garcia-Suarez
Date:
October 20, 2003 22:47
Subject:
Re: [perl #24250] "return" required in some anonymous closures
Message ID:
20031021075125.3d5c49b5.rgarciasuarez@free.fr
Dave Mitchell wrote:
> 
> I provisonally propose the new syntax:
> 
>     sub foo() : constant { ...}
> and
>     sub() : constant { ...}
> 
> which has the effect of:
> 
> for a named sub: as soon as the sub is compiled, it is executed once in
> scalar context, and the return value is used at the basis for a new
> CONST CV which replaces the original CV.

At least Eiffel uses the keyword "once" for such subroutines (that
are executed once.)  It may be more clear.

Offhand I don't remember seeing something like this in Perl 6.



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