develooper Front page | perl.perl5.porters | Postings from May 2008

Re: on the almost impossibility to write correct XS modules

From:
Juerd Waalboer
Date:
May 20, 2008 08:21
Subject:
Re: on the almost impossibility to write correct XS modules
Message ID:
20080520152102.GI2842@c4.convolution.nl
Rafael Garcia-Suarez skribis 2008-05-20 16:39 (+0200):
> > Maybe this should even be called Unicode::uc(), and uc() should
> > "default" to Unicode, with "use ASCII qw(uc);" and "use Unicode qw(uc);"
> > as ways to override the default.
> Likewise for char-classes ? So that's the unicode pragma I was talking
> about, with possible sub-pragmas :
>     use unicode qw(uc);
>     no unicode qw(regex);

The problem with a "no unicode" is that it doesn't say what the other
alternative is. I'd rather have two separate (mutually incompatible)
pragmas than one with an overloaded meaning for the unimport case.

> >>   Additionally, we can add a regexp flag qr//u, that says "this
> >>   regexp matches with Unicode semantics". (I'm thinking out loud
> >>   here)
> > I have suggested /u(nicode), /a(scii) before. These are "needed" in
> > addition to the pragma, because of qr//: there must be a way to
> > stringify the lexically selected behavior so it survives the end of the
> > lexical scope.
> What about (?u:...) ? What about mixing qr//u and qr//a in the same
> match ?

(?u:...) is the same as /u of course. That's what I meant with the
requirement of qr// being able to stringify any /u that it got (either
explicitly or through a pragma that makes it default).

I think it's straightforward. A certain set of character classes is
defined to behave in one way under /a, and another under /u. I'd say the
innermost defined one determines, so /foo(?a:\w)/u would match fool but
not fooĊ‚. 

> > However, there's also a way to
> Missing sentence ?

I think that was a window focus problem, and this was supposed to be
said on IRC :)

> > Indeed there could be a way to indicate "I intend this string to be a
> > byte string". I have a module, called BLOB.pm, in the works that makes
> > this very easy. I'll try to release it really soon so you can have a
> > look.
> Didn't you talk about it at one of the Amsterdam.pm meetings ?

Perhaps. I don't remember. I initially announced it at the Dutch Perl
Workshop and then lacked tuits to make it a release.

I might release it in its current state this evening. It believe that
although it's not thoroughly tested yet, it'll work well.
-- 
Met vriendelijke groet,  Kind regards,  Korajn salutojn,

  Juerd Waalboer:  Perl hacker  <#####@juerd.nl>  <http://juerd.nl/sig>
  Convolution:     ICT solutions and consultancy <sales@convolution.nl>
1;



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About