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

RE: marking can() coderef as a method

Thread Previous | Thread Next
Geoffrey Young
August 23, 2001 11:29
RE: marking can() coderef as a method
Message ID:

> -----Original Message-----
> From: Arthur Bergman []
> Sent: Thursday, August 23, 2001 2:24 PM
> To: Geoffrey Young;
> Subject: SV: marking can() coderef as a method
> > 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.  
> > 
> >   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... 
> > 
> > --Geoff
> > 
> > this patch is against the current bleedperl available from 
> rsync - a clean
> > build passes all tests on my system.
> This seems logical but unnecessary.
> When you have a coderef, why not just call perl_call_sv and 
> push the object as the first argument. Since can already 
> found the correct method, we don't need to search again using 
> call_method.

well, I'm neither an XS nor perlguts expert (actually I claim no knowledge
whatsoever ;)  but here was my (rather specific) problem.  

mod_perl has a method that accepts either a literal or a coderef.  If it
sees a literal it converts it into either class->method or class::method()
my searching for '->'.  if it gets passed a coderef, it just passes the
coderef perl_call_sv.

after thinking about it some, I said to myself "oh, you can't determine from
just a coderef whether it needs -> or not."  then a few months later I saw
the CvMETHOD_on macro somewhere and thought this might be the way.

> I also wonder why you want to know it is a method, you cannot 
> call it unless you have an object connected to it, and then 
> you already know it is a method.

that may be.  as I said, this isn't my area, but with the patch I was able
to get mod_perl to behave the way I wanted with a minimum of effort.  Doug
or someone similarly qualified might say phooey and know of a better way.  I

I'm not trying to introduce something to core just to meet my whims - I
thought it might have a broader applications than I could dream up is all.
which is why I posed the question to the people who know :)


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