emacs-devel
[Top][All Lists]
Advanced

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

Re: Escape syntax in docstrings


From: Mattias Engdegård
Subject: Re: Escape syntax in docstrings
Date: Thu, 23 Mar 2023 23:02:08 +0100

23 mars 2023 kl. 21.46 skrev Chen Zhaoyang <chenzhauyang@gmail.com>:

> Since when did emacs become stricter when enforcing the escape syntax in
> docstrings? On 27.1 (built by debian), this function evals to no error:
> 
> (defun slash-in-docstring ()
> "\x -> x"

Yes, this was changed recently, but I feel vindicated by your report: "\x" 
never meant what the author thought it did (or at least what I think the author 
thought it did): it is a hex escape without digits and used to be equivalent to 
"\000", yielding the control character NUL. Run `C-h f slash-in-docstring` in 
Emacs 29 or older and see for yourself.

The probability of anyone writing \x expecting NUL is, well, nil. It's 
guaranteed to be a mistake.

In fact, if you alpha-rename that doc string to "\y -> y" then Emacs won't 
complain but the doc string will still be wrong and behave as if you wrote "y 
-> y". (The 'relint' tool finds these things as an extra service.)

(That Emacs doesn't reject undefined character escape sequences such as "\y" is 
not only a constant source of bugs, it also makes it difficult for us to add 
new escape sequences without worrying about breaking some (misguided) code. 
Almost every other language complain about this.)

Thanks for your report -- I scanned all packages on my disk for occurrences of 
\x without digits when making the change and found none. Shame on me for not 
using HOL!

> (defun agda-input-compose (f g)
>  "\x -> concatMap F (G x)"

Good catch. Would you tell the Agdas about it?

> Can we document this change of behavior? 

Will do.





reply via email to

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