unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Escape syntax in docstrings
@ 2023-03-23 20:46 Chen Zhaoyang
  2023-03-23 22:02 ` Mattias Engdegård
  2023-03-24  4:04 ` Ruijie Yu via Emacs development discussions.
  0 siblings, 2 replies; 15+ messages in thread
From: Chen Zhaoyang @ 2023-03-23 20:46 UTC (permalink / raw)
  To: emacs-devel

Dear friends,

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"       
 nil)

but on 30.0.50, the above lisp function will get emacs to complain
`(error "Invalid escape character syntax")`. I believe this is a recent
change. I didn't build from the master branch for only about a week; I
recompiled my emacs yesterday from master and found out that
the lisp code ships with the HOL theorem prover broke on me in the
following two functions (their docstrings, rather, the functions
themselves are fine):

(defun hol-input-compose (f g)
  "\x -> concatMap F (G x)"
  (lexical-let ((f1 f) (g1 g))
    (lambda (x) (hol-input-concat-map f1 (funcall g1 x)))))

(defun hol-input-or (f g)
  "\x -> F x ++ G x"
  (lexical-let ((f1 f) (g1 g))
    (lambda (x) (append (funcall f1 x) (funcall g1 x)))))

The fix is trivial of course
(https://github.com/HOL-Theorem-Prover/HOL/commit/e9e9506209e82b8037b8a4066b7fd672e961c08a),
but going through the recent logs I don't quite find commits explicitly
about escape character in docstrings (I think commit b8e7061232f `Remove
recursion from character escape handling in reader` probably has
something to do with it, but I am not so literate in C).

I am aware that the agda project also uses slash to represent lambdas in
their elisp code
(https://github.com/agda/agda/blob/35bcdbc04e47e49a436b5a097312a672e0ad0074/src/data/emacs-mode/agda-input.el#L56,
courtesy of <ski> on #emacs):

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

Once this change lands in the next release, this lisp function will certainly break.

Can we document this change of behavior? 

-- 
Chen Zhaoyang




^ permalink raw reply	[flat|nested] 15+ messages in thread
* Re: Escape syntax in docstrings
@ 2023-03-23 22:32 Chen Zhaoyang
  2023-03-24 13:22 ` Mattias Engdegård
  2023-03-24 15:58 ` David Ongaro
  0 siblings, 2 replies; 15+ messages in thread
From: Chen Zhaoyang @ 2023-03-23 22:32 UTC (permalink / raw)
  To: emacs-devel; +Cc: emacs-devel

Mattias Engdegård <mattias.engdegard@gmail.com> writes:

> 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.

Thank you for you clarification! I totally did not know about the fact
that "\x" means NUL in docstrings. 
I do agree that using the slash to represent λ in docstring is not so
good to begin with.

>> (defun agda-input-compose (f g)
>>  "\x -> concatMap F (G x)"
>
> Good catch. Would you tell the Agdas about it?

Yeah, I am grepping for cases like this and will submit a patch to them soon.

>> Can we document this change of behavior? 
>
> Will do.

Cool, thank you again!

-- 
Chen Zhaoyang




^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2023-03-28 15:23 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-03-23 20:46 Escape syntax in docstrings Chen Zhaoyang
2023-03-23 22:02 ` Mattias Engdegård
2023-03-24 16:17   ` James Cloos
2023-03-24 21:17   ` Philip Kaludercic
2023-03-28 12:14   ` Robert Pluim
2023-03-28 12:27     ` Andreas Schwab
2023-03-28 15:23       ` Robert Pluim
2023-03-24  4:04 ` Ruijie Yu via Emacs development discussions.
2023-03-24  4:44   ` Chen Zhaoyang
2023-03-24 18:29     ` Eli Zaretskii
2023-03-24 19:58       ` Chen Zhaoyang
  -- strict thread matches above, loose matches on Subject: below --
2023-03-23 22:32 Chen Zhaoyang
2023-03-24 13:22 ` Mattias Engdegård
2023-03-24 15:58 ` David Ongaro
2023-03-24 17:22   ` Chen Zhaoyang

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).