develooper Front page | perl.perl5.porters | Postings from September 2014

[perl #116735] lexical subs don't seem to honor prototypes

Thread Previous | Thread Next
From:
Father Chrysostomos via RT
Date:
September 11, 2014 03:39
Subject:
[perl #116735] lexical subs don't seem to honor prototypes
Message ID:
rt-4.0.18-19123-1410406780-1529.116735-15-0@perl.org
On Sun Jun 02 13:36:14 2013, sprout wrote:
> On Mon Feb 18 10:55:41 2013, pcm wrote:
> > I'd been playing with ways to fix this, and checked in my work-in-
> > progress (as a single large-ish commit) this morning: 
> > https://github.com/PeterMartini/perl/commit/lexical-proto

That URL does not work any more.

> > 
> > There are two components, which are separable:
> > 
> > 1. Change ck_subr to grab the CV directly from padcv if that's the last 
> > op, which is the simple fix, and I'll defer to anyone more knowledgeable 
> > on whether it's the correct fix.
> 
> I’ve done what I think is the more correct fix, which is to avoid
> generating two disparate op trees to begin with, in commit 9a5e6f3cd84.
> 
> > 2. Father C had noted that the Perl_call_checker API passes a GV*, which 
> > no longer works, since a lexical sub won't have a GV.  The solution as 
> > of right now is a faked up GV, which as noted is not ideal, as it 
> > includes the current package.
> > 
> > I added an alternate API, Perl_call_checker_sv and appropriate get/set 
> > functions, so that the name could be passed be specified as an SV*.  For 
> > backwards compatibility reasons, if a custom Perl_call_checker was set, 
> > it will use that; if a custom Perl_call_checker_sv was set, it will use 
> > that; otherwise, it will use the default Perl_call_checker_sv.
> > 
> > These both get stored in checkcall magic, so only one can be active at a 
> > time.  If the current, GV form, is used in a set, and the SV form is 
> > used in a get, the get returns a NULL pointer.  In the reverse case, 
> > where the new API is used to set an override, and the old API is used to 
> > get it back, the code will croak.  The reason for the difference is the 
> > old API implies the call will always succeed, so returning a NULL would 
> > be a bad idea, while the new version is documented to return NULL to 
> > indicate that the alternate API should be used.
> > 
> > ************
> > 
> > Now that I see that prototypes are actually partially honored, applying 
> > just the first part would get us to consistency with minimal risk of 
> > side effects, and the second part can be polished up as a nice to have.
> 
> Would you be willing to do that? :-)

I was about to do that (separate out part 2 from your patch and polish it up), but, as noted above, cannot access that URL.

Do you still have the patch floating around somewhere?  If not, I will just have to write it from scratch.  I need it right now for the stuff I’m doing on the sprout/cvgv branch.  (ck_subr reifies GVs and I need the alternate call checker API to remove the need for that.)

-- 

Father Chrysostomos


---
via perlbug:  queue: perl5 status: open
https://rt.perl.org/Ticket/Display.html?id=116735

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