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

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

Thread Previous | Thread Next
Nicholas Clark
October 20, 2003 16:06
Re: [perl #24250] "return" required in some anonymous closures
Message ID:
On Mon, Oct 20, 2003 at 11:53:03PM +0100, Dave Mitchell wrote:
> Thus, I like Elizabeth's suggestion of using a compile-time attribute
> to explicitly turn on this special behaviour, and thus to not suprise the
> ordinary user.

I like it, but I'm worried that I may be hasty, so I'd like to to simmer
for a bit more before committing anything half baked to maint.
(Woohoo. Mixed metaphors. Flavour clash)

It would be nice if this (or something related) also provided a solution to
how to export constants that can be autoloaded. Currently all the core
extensions (such as Fcntl, POSIX, Socket ...) have @EXPORT or @EXPORT_OK
full of names of "subs" that are actually defined as needed by AUTOLOAD
(these days usually by a call into code generated by ExtUtils::Constant,
but that's not important).

As these "subroutines" are actually constant value returning, it would
be nice if

a: there was a way to declare them them from henceforth to be constants
   without getting the prototype redefinition warning. (And its implication
   that you're making a real change to the parsing behaviour)

   (Maybe I'm confused. Maybe we just need Exporter to declare them with
    a prototype) (Without making it slower)

b: there was a way to make the tokenizer/optimizer whatever call the sub
   to find the value whenever it is referred to. (given that it's actually
   a constant sub)

Note that you can't simply call the AUTOLOAD routine on all the subs as
you export them, as there are bazillions, and most are not used by most

Nicholas Clark

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