emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: modern regexes in emacs


From: Mattias Engdegård
Subject: Re: modern regexes in emacs
Date: Wed, 27 Feb 2019 13:09:23 +0100

26 feb. 2019 kl. 15.33 skrev Andreas Schwab <address@hidden>:
> 
> If you want to byte-compile a form that contains a regexp object, a
> proper read syntax is required.
> 
> The object types without read syntax are rather ephemeral, unlikely to
> occur in byte-compiled forms.

Thanks for pointing that out. I'm not sure how it would work -- please bear 
with me.

Suppose we want to write (looking-at (pcre "a(b|c)")).
Then `pcre' is a macro returning a mutable object with the regexp in some 
canonical form -- a traditional Emacs regexp, perhaps, or normalised rx or 
something else. The object also has space for the internal compiled pattern, 
roughly struct re_pattern_buffer today.

As Richard pointed out, it is polite to make the object human-readable (for 
debugging, if nothing else). This means that we are either satisfied with the 
readability of the canonical form, or the original pattern is included around 
for this purpose.

Then (pcre "a(b|c)") might produce #s(regexp "a\\(b\\|c\\)" nil), which can be 
serialised and read, even by humans.
After its first use, the last slot would have become something like 
#<compiled-regexp 0xabc123>, but that would not occur in byte-compiled elisp 
code.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]