Re: New extension: re2

From: Date: Mon, 20 Jun 2011 19:26:33 +0000
Subject: Re: New extension: re2
References: 1  Groups: php.pecl.dev 
Request: Send a blank email to pecl-dev+get-8381@lists.php.net to get a copy of this message
2011/6/20 Miroslav Kubelík <koubel@php.net>: >> I've put together an extension which wraps RE2 - an alternative to >> PCRE which can be much faster and be constrained to memory limits > > Generally it can be useful. Can be PCRE used in mode without backtracking? > If yes, I cannot see many benefits over PCRE. Hi, PCRE provides a backtracking limit (available in PHP via pcre.backtrack_limit) but isn't much use when it's disabled. It needs a value of at least 2 to match /foo/ against "foo". RE2's memory limit is much more useful. The main advantage of RE2 is that it's guaranteed to match in time linear to the input. > Small comment when I quick look the header file: > > Why these two are necessary? Just one isn't enough? > > PHP_METHOD(RE2_Options, getOneLine); > PHP_METHOD(RE2_Options, getOneLine); > > PHP_METHOD(RE2_Options, setOneLine); > PHP_METHOD(RE2_Options, setOneLine); Cheers, I've removed the duplicates now. > And small notice about error handling - btw how your API has handled errors. > > I have very bad experience with the error handling in PCRE. > See > > http://translate.google.com/translate?u=http%3A%2F%2Fphpfashion.com%2Fzradne-regularni-vyrazy-v-php&ie=UTF8&sl=cs&tl=en > (original language is Czech) > > Don't make silly API for errors and return values as PCRE has. All functions return false and raise an error on invalid patterns, so it doesn't have PCRE's ambiguity. When the log_errors setting is on, RE2 itself outputs errors to stderr, which is handy for development but not so useful in production. I'm not entirely satisfied with that so I'm open to ideas, but I think an exception would be quite unintuitive. > Maybe you can drop functional API and use only OO API with Exception. I think there's value in the familiarity of the ext/prce-style functional API so I don't intend to drop that. However adding an OO API is certainly an option, and then it would indeed make sense to use exceptions. Regards, Arpad

« previous php.pecl.dev (#8381) next »