develooper Front page | perl.perl5.porters | Postings from August 2001

Re: marking can() coderef as a method

Thread Previous | Thread Next
Nick Ing-Simmons
August 24, 2001 06:29
Re: marking can() coderef as a method
Message ID:
Geoffrey Young <> writes:
>hi all...
>  I thought it might be genuinely useful to mark a coderef returned by
>UNIVERSAL::can() as being a method so that XS routines can know whether to
>use perl_call_method or perl_call_sv on it.  

I don't think so. You can always use perl_call_sv on a coderef.
The fact that ->can found it does NOT tell you whether you need 
to push the object arg - and there is no point in the perl_call_method

>  please forgive me if I misunderstand the purpose of CvMETHOD_on - I
>scoured the archives but could only find a smattering of information and I'm
>probably a bit out of my league here anyway... 

CvMETHOD corresponds to the : method attribute you can give to subs.
Its original use was for Malcolm's original thread locking scheme.
A sub which had : locked and : method locked the _object_ one 
which just had : locked locked the CV itself.

One could make a case that ->can should _fail_ unless sub had : method 
attribute - but I won't 'cos lots of OO perl code (including mine)
does not annotate methods. 

>this patch is against the current bleedperl available from rsync - a clean
>build passes all tests on my system.
>--- universal.c.old	Thu Aug 23 13:14:18 2001
>+++ universal.c	Thu Aug 23 13:38:27 2001
>@@ -219,8 +219,10 @@
>     if (pkg) {
>         GV *gv = gv_fetchmethod_autoload(pkg, name, FALSE);
>-        if (gv && isGV(gv))
>+        if (gv && isGV(gv)) {
>+	    CvMETHOD_on(GvCV(gv));
> 	    rv = sv_2mortal(newRV((SV*)GvCV(gv)));
>+        } 
>     }
>     ST(0) = rv;
Nick Ing-Simmons

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