pcre, bifs, drivers and ports

Ernie Makris ernie.makris@REDACTED
Mon Jul 31 16:56:42 CEST 2006


Hi Mats,

I'd definitely be interested in seeing the code, or even an overview of
the process to properly add a bif.

I think the best thing I can do is add in the pcre library, create the
bif and then run it indefinitely in
a loop of regex tests to observe the memory behavior of the VM.

Thanks
Ernie

Mats Cronqvist wrote:
> Ernie Makris wrote:
>> Hello Erlangers,
>>
>> One thing I wanted to start a discussion on is getting pcre style
>> regexps in erlang. The question
>> I pose to the list is: What would be the best way to integrate the pcre
>> library into erlang.
>> The possible approaches I've seen so far are:
>> - create a linked in driver
>> - create a port program
>> - create new bifs (I'd really like this)
>
>   a bif is the way to go, imo.
>
>> My obvious concerns are:
>> - How stable is the C pcre library for long running servers
>> - Stability implies:
>>     - Memory leaks
>>     - SIGSEGVs
>>
>> I would love the library calls in erlang to be bifs. Are there any
>> external examples, aside from just looking at the source that
>> demonstrate how to cleanly add a new bif?
>
>   two weeks ago me and a colleague implemented two new bifs; re:grep/2
> and re:compile/1.
>
>   documentation is a bit scarce;
>
> re:compile([RegExp]) -> [RegExpC]
> re:grep(Str,[RegExp]) -> [MatchItem]
> RegExp = string()
> RegExpC = term()
> MatchItem = no_match | {int(Beg),int(End),[string(SubMatch)]} |
> {error,{string(ErrorStr),int(ErrorChar)}}
>
>   we have not yet observed any problems with stability.
>
>   OTP has indicated that they will not introduce any bif that does not
> execute in bound time, or yields. i believe this can be met by
> limiting the length of the string and the regexp.
>
>   if there is interest, we can probably make the code available.
>
>   mats
>



More information about the erlang-questions mailing list