emacs-devel
[Top][All Lists]
Advanced

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

Re: Instead of pcase


From: Richard Stallman
Subject: Re: Instead of pcase
Date: Tue, 19 Dec 2023 22:28:03 -0500

[[[ To any NSA and FBI agents reading my email: please consider    ]]]
[[[ whether defending the US Constitution against all enemies,     ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]

I find these examples hard to understand because of the complexity
caused by the functions called `bar'.  I could not fully make sense of
the first one: I don't understand what you intend it to do, or what
you think it might do, or why it might do that.

It is indeed painfully complex, but I don't think that is the fault of
cond*.

Is it possible that the explanation of a constrained variable patterm
is not clear?

    Constrained variable: (TESTFN VARIABLE OTHER-ARGS...)

      This matches any value VALUE provided (TESTFN VALUE OTHER-ARGS...)
      evaluates to true.  If so, it sets VARIABLE to VALUE.

         (symbolp sym)    Match any symbol, store it in `sym'.
         (> num-foos 1)   Match any thing greater than 1, store it in 
`num-foos'.

Only the first argument to a TESTFN is a kind of subpattern.  The
OTHER-ARGS are handled are not patterns to match; they are expressions
to evaluate.  Their values are passed to TESTFN as in an ordinary
function call.

If TESTFN is your function `bar', it will then receive its arguments
in the usual way and do what it is defined to do.  It is used as a
predicate, so all that matters is whether its return value is non-nil.

The first parameter of `bar' will be data that this subpattern
may match or not.  The remaining parameters of `bar' will be the
results of evaluating OTHER-ARGS...


-- 
Dr Richard Stallman (https://stallman.org)
Chief GNUisance of the GNU Project (https://gnu.org)
Founder, Free Software Foundation (https://fsf.org)
Internet Hall-of-Famer (https://internethalloffame.org)





reply via email to

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