emacs-devel
[Top][All Lists]
Advanced

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

Re: pcase bindings in patterns with complicated logic


From: Ihor Radchenko
Subject: Re: pcase bindings in patterns with complicated logic
Date: Sun, 14 Jan 2024 15:42:50 +0000

Thierry Volpiatto <thievol@posteo.net> writes:

> [ BTW I don't understand why `app` pattern exists as long as now `pred` is
> supporting an extra arg ]

Isn't it explained right in the manual?

‘(app FUNCTION PATTERN)’
     Matches if FUNCTION called on EXPVAL returns a value that matches
     PATTERN.  FUNCTION can take one of the forms described for ‘pred’,
     above.  Unlike ‘pred’, however, ‘app’ tests the result against
     PATTERN, rather than against a boolean truth value.

> Also I would give a warning to extensions developers that want
> compatibility with older emacs:
>
> pcase has evolved and doesn't behave as in older emacs, so try you pcase
> statements on each emacs you want to support, for example (pred (not
> ...)) is not supported in older Emacs.

Compiler takes care about this warnings. For example,
(pcase '(1)
  ((pred (not cdr)) "true"))

in Emacs 26 will indicate problems

Compiling file /tmp/test.el at Sun Jan 14 16:41:32 2024
test.el:2:15:Warning: reference to free variable ‘cdr’

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>



reply via email to

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