emacs-devel
[Top][All Lists]
Advanced

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

Re: pcase defuns


From: Tassilo Horn
Subject: Re: pcase defuns
Date: Sun, 19 Dec 2021 18:16:29 +0100
User-agent: mu4e 1.7.5; emacs 29.0.50

Andrew Hyatt <ahyatt@gmail.com> writes:

Hi Andrew,

> I have a solution for this: a crude one: I just sort all the rules
> according to their flattened length. So the most complicated ones
> should get tried first, which I think is something that can
> communicated to the user.

Hm, well, in that case (a ,var) is longer than (a b) so the former will
always be taken although a user might have them ordered the other way
round and expect (a ,var) only to match if the second argument is not b.

> You've hit upon the issue with these types of systems.  Powerful, easy
> to use, but dispatch rules are always vague.  The same thing can
> happen with cl-defmethod, IIRC, where you can have two rules that both
> seem like they should take precedence.

Oh dear, my head becomes dizzy when reading their dispatch behavior at
(info "(elisp) Generic Functions").  Well, I mean, the typical uses can
be pretty easy to understand but if you mix and match different kinds of
specifiers, it becomes unwieldy, like what happens when you have two
methods where one specifies the first argument must be an integer and
the other says it applies if the first argument is (eql 42) [where 42 is
obviously an integer]?  I can't read a priority order between different
kinds of specifiers...

Bye,
Tassilo



reply via email to

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