help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: Quick pcase question


From: Eric Abrahamsen
Subject: Re: Quick pcase question
Date: Thu, 03 Mar 2016 09:13:45 +0800
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux)

phillip.lord@russet.org.uk (Phillip Lord) writes:

> Michael Heerdegen <michael_heerdegen@web.de> writes:
>
>> Eric Abrahamsen <eric@ericabrahamsen.net> writes:
>>
>>> But the fact is that pcase is (very complex and very useful) syntax
>>> sugar. I just wrote a pcase clause that looks like:
>>>
>>> `((,(and f-string (pred stringp)) . ,(and class (pred symbolp)))
>>> . ,(and regexp (pred stringp)))
>>>
>>> And that's kind of awful. The whole point of pcase should be concision,
>>> but that looks pretty terrible.
>>
>> :-P
>>
>> Maybe separate the testing and the binding operations, like:
>
> What about this?
>
> (pcase tst
>   ((and
>     `(symbolla . ,x)
>     (guard (stringp x)))
>    (message "cdr is a string: %s" x)))

That seems quite a bit better -- I really haven't yet wrapped my head
around the possible permutations of upatterns and qpatterns. Still a bit
ungainly when you have multiple clauses, but it does look a little more
intuitive.

Thanks to you both!

E




reply via email to

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