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

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.

Reply via email to