[Cc to mailing list]
On Mon, 20 Dec 2004 17:44:05 -0800, Dave Roberts ldave@droberts.com wrote:
Does CL-PPCRE cache scanners when you just pass in a string to scan or scan-to-strings? That is, if I just say (SCAN-TO-STRINGS "a regex" "string-to-scan for a regex"), is it compiling "a regex" to a scanner every time, or is it caching that expression for later?
Hi Dave!
There's more than one answer to this question:
1. CL-PPCRE never compiles scanner in the sense that the Lisp compiler is invoked. It just combines existing closures which means, e.g., that in delivered applications you can excise the compiler from the image and CL-PPCRE will still work.
2. Nevertheless, creating a scanner (as with CREATE-SCANNER) still takes some time because the regex has to be parsed and the chain of closures has to be created in memory.
3. If it encounters a constant (see CONSTANTP in the CLHS) regular expression, CL-PPCRE uses compiler macros to make sure the scanner is created only once - at load time. See this for an explanation:
http://www.pentaside.org/paper/compilermacro-lemmens/compiler-macros-for-publication.txt
So this'll apply to your example above.
4. I briefly thought about generally caching scanners but realized that it is kind of orthogonal to the rest of CL-PPCRE so I'll leave it up to the user to do it if he needs it.
Cheers, Edi.
cl-ppcre-devel@common-lisp.net