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

Re: compile time AUTOLOAD calling (constant folding)

Thread Previous | Thread Next
From:
bulk 88
Date:
October 25, 2016 05:20
Subject:
Re: compile time AUTOLOAD calling (constant folding)
Message ID:
CY4PR04MB06639DB918EA74E3E2D310C0DFA80@CY4PR04MB0663.namprd04.prod.outlook.com
Dave Mitchell wrote:
> On Sat, Oct 22, 2016 at 02:10:31AM -0400, bulk88 wrote:
>> I'm thinking of modifying the gv_fetchsv() at http://perl5.git.perl.org/perl.git/blob/01b515d1d793fe9ee31ac67de850d943ce109686:/op.c#l9856
>> 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


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