develooper Front page | perl.perl5.porters | Postings from January 2003

Re: Checking if regex matches from XS

Thread Previous | Thread Next
From:
Dave Rolsky
Date:
January 19, 2003 09:34
Subject:
Re: Checking if regex matches from XS
Message ID:
Pine.LNX.4.51.0301191128430.12144@urth.org
On Sun, 19 Jan 2003, Nick Ing-Simmons wrote:

> Dave Rolsky <autarch@urth.org> writes:
> >I've read the Jenness/Cozens book and the various perldocs on XS, but I
> >can find no hint of how to use the regex engine from XS.
>
> It is tricky and risky - trying to use perl's regex engine
> to subsitute for Tcl's is one of the recurring porting issues
> with perl/Tk.
>
> The main snag (as I recall) is that in perl you need an "OP" in order
> to call some of regex engine.

Sigh ...

I was afraid someone would say something like that.

> Unless you _really_ need this I strongly recommend writing the
> "leaf" functions for this in perl and perl_call_sv()-ing them from your
> XS code.

Well, the main reason Ilya and I are working on this XS code (for
Params::Validate) is to speed it up.  Calling back and forth to Perl
unnecessarily somewhat defeats the purpose.

> Unless Hugo wants to give us a clean interface?

That'd be cool for the future.

One thing I'd say in general about XS is that it just doesn't expose
enough of Perl's functionality, at least not in what's documented.  And I
include the Jenness/Cozens book in that documentation (good book, but it
doesn't cover everthing I _want_ to do with XS).

For example, in the Params::Validate XS code we need to find out what
package the caller is in.  Now, obviously Perl can do this, because we
have the caller() function.  Ilya somehow found the CopSTASHPV macro, and
then I found an equivalent way to do this for Perl 5.00503, but it's all a
nasty hack since this isn't a documented interface.

It seems to me that ideally you could call any Perl function from XS.  I
realize that's extremely difficult, but there must be some subset of
Perl's functionality easily available from XS that isn't documented (like
CopSTASHPV).


-dave

/*=======================
House Absolute Consulting
www.houseabsolute.com
=======================*/

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