emacs-devel
[Top][All Lists]
Advanced

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

Re: Instead of pcase


From: Eli Zaretskii
Subject: Re: Instead of pcase
Date: Fri, 01 Dec 2023 08:24:10 +0200

> Date: Thu, 30 Nov 2023 21:30:00 +0100
> From:  Michael Heerdegen via "Emacs development discussions." 
> <emacs-devel@gnu.org>
> 
> 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?

It was taken from one of the posted examples, perhaps with a typo.
But that is not relevant.  Are you saying pcase doesn't have
constructs like (`(SOMETHING...), or that SOMETHING doesn't use
periods in places where they are redundant in "normal" ELisp code?

IOW, these details are not the point, the point is something else
entirely, see below.

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

My point focuses on the problems this syntax causes to someone who
doesn't have intimate knowledge and a lot of practice with pcase.
Thus, it is a disadvantage.  Whether it is outweighed by advantages is
a separate discussion; my message just pointed out that the
disadvantage exists and is real, because Lynn seemed to be missing
that point.

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

It is a disadvantage if one needs to consult doc strings all the time
while reading code.  And in this case, the doc string is quite long
and highly non-trivial (and rightfully so, since the DSL is a rather
complex one).

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

If one bumps into such constructs very frequently, then eventually one
will become familiarized with them.  But if the frequency is low
enough, one could easily forget the details, and then one will need to
consult the documentation again the next time.

Please don't underestimate these difficulties, even if you don't share
them.



reply via email to

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