On Fri, May 14, 2004 at 11:07:35AM +0200 Rafael Garcia-Suarez wrote:

> Tassilo von Parseval wrote:
> > > > > Hmm, maybe this means that a _new_ macro should be added for XS
> > > > > writers, that get DEFSV right, by testing whether there's a lexical $_
> > > > > in scope. Opinions ?
> > > > 
> > > > Well, yes, please! Ideally, it would be backwards-compatible so that
> > > > people could already start using it now (unless of course they
> > > > deliberately want $::_).
> > > 
> > > That's the job of PPPort, isn't it.
> > 
> > For instance. But pre-blead perls have no concept of lexically scoped $_
> > so it would make no sense to look for one on the pad. So those macros
> > would therefore look different on older perls (they'd simply expand to
> > DEFSV).
> 
> Something like that maybe : (I don't quite like the name "UNDERBAR" but
> I haven't found anything shorter)
> 
> for perl >= 5.9.1 :
> 
> #define dUNDERBAR I32 padoff_du = pad_findmy("$_")
> #define UNDERBAR ((padoff_du == NOT_IN_PAD \
>           || PAD_COMPNAME_FLAGS(padoff_du) & SVpad_OUR) \
>       ? DEFSV : PAD_SVl(padoff_du))
> 
> For older perls :
> 
> #define dUNDERBAR /**/
> #define UNDERBAR DEFSV

Looks convenient. You are the lexical underbar guru, so I also trust you
that it's correct. If it isn't yet in blead, it should go there (and
also into Devel::PPPort).

> Defining a dUNDERBAR macro has the advantage that the pad_findmy lookup
> is done only once. In a XSUB lexical scoping isn't likely to change.

And even if it happens, this can be handled easily.

    dUNDERBAR;
    ...
    {
        ENTER;
        dUNDERBAR;
        ...
        LEAVE;
    }

Btw, we can't rename dUNDERBAR to wUNDERBAR (as a little candy for the
German XS writers), can we? ;-)

Tassilo
-- 
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval

Reply via email to