emacs-devel
[Top][All Lists]
Advanced

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

Re: Instead of pcase


From: Michael Heerdegen
Subject: Re: Instead of pcase
Date: Thu, 30 Nov 2023 21:30:00 +0100
User-agent: Gnus/5.13 (Gnus v5.13)

Eli Zaretskii <eliz@gnu.org> writes:

> I think you are missing the point.  The point is that pcase has so
> many semi-magical syntax features that use punctuation characters in
> creative ways that every extra punctuation character presents a
> puzzle.  Faced with
>
>   (`(,hookfun . ,start ,end))

This is not a valid expression and will be rejected by the reader.  Was
it a typo or did you think this would be valid?

> one immediately asks himself why the period, where in "normal" Lisp
> expressions it would be completely redundant?

As had been said: the syntax has been chosen intentionally to underline
that it is important to view the matched thing as a cons instead of a
list.  If people get crazy about the dot, we can choose a different
syntax without the dot.  It is not necessary to use this syntax (unless
the cdr is not a list).  This point is not about `pcase' but about how
the author has chosen to write the pattern.

> The fact that it is there then leaves one wondering whether that
> period has some "magical" meaning.

As an alternative one can have a look at the docstring.  And learn the
read syntax of cons cells in Lisp.  There is not more to wonder about as
there is to wonder about the identity

 (X . (Y ...)) == (X Y ...)

People should familiarize themselves a bit with Lisp when working with
the Emacs Lisp source code.  I know the above identity can be confusing
_once_, in different situations, not only in `pcase', but it is
something on has to know anyway, and this is really not that difficult
or magical.


Michael.




reply via email to

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