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

Re: compile time AUTOLOAD calling (constant folding)

Thread Previous
Dave Mitchell
October 25, 2016 10:10
Re: compile time AUTOLOAD calling (constant folding)
Message ID:
On Tue, Oct 25, 2016 at 05:20:23AM +0000, bulk 88 wrote:
> Dave Mitchell wrote:
> > On Sat, Oct 22, 2016 at 02:10:31AM -0400, bulk88 wrote:
> >> I'm thinking of modifying the gv_fetchsv() at
> >> to fall back to autoload sub if it exists, and if AUTOLOAD's CV has CvCONST
> >> flag, since I dont want to add a new flag, AUTOLOAD sub will be called at
> >> compile time, not runtime from pp_entersub. Any comments?
> > 
> > That doesn't sound very useful to me. I think it will very rare for the
> > AUTOLOAD sub to be a const sub (so all the autoloaded constants  are the
> > same value).
> > 
> I think that there might be a bug/breakage somehow if an AUTOLOAD sub is 
> called at BEGIN/CHECK time when it previously was always called at RUN time.
> For example, I think this might be a problem but Im not 100% sure. If 
> the AUTOLOAD is actually a marshalling library to another language 
> (SOAP/JS/Python/Tcl bridge), so AUTOLOAD executes real methods in 
> another language, not just returns constants, there would be side 
> effects of calling AUTOLOAD for every unknown bareword token found in 
> the perl code, so an AUTOLOAD sub somehow has to request for the 
> constant folder to call it, instead of always executing the AUTOLOAD sub 
> for unknown barewords from inside toke.c/ck_*().
> I'll probably have to add another Cv* constant flag and not reuse 
> CvCONST flag. Currently CVf_ANONCONST/0x20000 is the highest flag in the 
> U32, so there no shortage of bits in the CvFLAGS.

Its not at all clear to me what your proposal is. Under what circumstances
would such a flag get set on the AUTOLOAD sub?

If I understand the original TODO proposal, it was to allow in some
fashion for a module to mark certain bareword names as compile-time
resolvable via AUTOLOAD, rather than for *every* bareword to be
compile-time AUTOLOADed. What mechanism, if any, is in place now that
caused the TODO entry to be deleted, I don't know.

"Strange women lying in ponds distributing swords is no basis for a system
of government. Supreme executive power derives from a mandate from the
masses, not from some farcical aquatic ceremony."
    -- Dennis, "Monty Python and the Holy Grail"

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