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

Re: compile time AUTOLOAD calling (constant folding)

Thread Previous | Thread Next
bulk 88
October 25, 2016 05:20
Re: compile time AUTOLOAD calling (constant folding)
Message ID:
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.

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