3 ms·
This has been available in Lisp since at least 2004. https://github.com/edicl/cl-ppcre/ https://github.com/edicl/cl-ppcre/
by nemoniac 3y ago
This has been available in Lisp since at least 2004.
https://github.com/edicl/cl-ppcre/ https://github.com/edicl/cl-ppcre/
- paulddraper 3y agoGreat thanks, I'll use that
- 0xf00ff00f 3y agoC++ has had run-time regular expressions in its standard library since C++11, but this is about compile-time regular expressions
- burntsushi 3y agoI've never used cl-ppcre myself, but its docs[1] claim that it provides compile-time regexes: > CL-PPCRE uses compiler macros to pre-compile scanners at load time if possible. This happens if the compiler can determine that the regular expression (no matter if it's a string or an S-expression) is constant at compile time and is intended to save the time for creating scanners at execution time (probably creating the same scanner over and over in a loop). [1]: https://edicl.github.io/cl-ppcre/ https://edicl.github.io/cl-ppcre/
- foota 3y agoI think this is more like caching the regex than creating it at compile time? Load time I think is basically runtime. I think lisp can be loaded and then rehydrated later, but I'm not sure how common that is.
- burntsushi 3y agoHard to say exactly since I don't have experience with cl-ppcre, but this line seems to suggest something is actually happening at complile time: > This happens if the compiler can determine that the regular expression (no matter if it's a string or an S-expression) is constant at compile time If this were just a run of the mill caching mechanism, then whether the pattern was a constant at compile time wouldn't matter.
- sebazzz 3y agoAlso in .NET since version 7. It generates quite nice commented code too. https://learn.microsoft.com/en-us/dotnet/standard/base-types/regular-expression-source-generators https://learn.microsoft.com/en-us/dotnet/standard/base-types...