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: Thierry Volpiatto
Subject: Re: pcase bindings in patterns with complicated logic
Date: Sun, 14 Jan 2024 15:58:56 +0000

Ihor Radchenko <yantar92@posteo.net> writes:

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

Perhaps it is right but I don't understand it, an example in the manual
would be welcome (if there is one I missed it).

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

I already hit this warning and had hard time figuring what was wrong, in
test.el it is easy to find but in a large file the compiler doesn't
bring you always to the right place.

-- 
Thierry

Attachment: signature.asc
Description: PGP signature


reply via email to

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