emacs-devel
[Top][All Lists]
Advanced

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

Re: cond*


From: Ihor Radchenko
Subject: Re: cond*
Date: Wed, 03 Jan 2024 15:57:22 +0000

Richard Stallman <rms@gnu.org> writes:

>   > Or, better, allow VARIABLE to be in an arbitrary argument of PRED:
>
> I understand that in the abstract.  I just don't see any syntax that
> makes sense to use for it.
>
>   > ,(PRED ARG1 ARG2 !VARIABLE ARG3 ...)
>
> I don't understand this syntax.  `!' as no special meaning.
> It cam't magically have a special meaning in a cpnd* pattern.
> It would be part of the variable name.

> This feature makes sense, and I've defined a syntax for it already:
>
>    (constrain VARIABLE (PRED ARG1 ARG2 VARIABLE ARG3...))

It is technically possible to assign special meaning to !name in macros.
However, I do agree that "constrain" should be good enough to the use
case that I proposed.


>   > What about allowing a construct like ,((plist-get plist) property) that
>   > will test for PROPERTY being in PLIST?
>
> I do not understand what you mean by  ,((plist-get plist) property).
> I am simply lost here.  I don't know which parts of that are supposed
> to be fixed structure and which parts refer to things in the cond* call.

[ I withdraw this proposal as "constrain" is good enough, but still
  replying to provide context for my previous idea ]

I was referring to what "pred" in `pcase' does:

‘(pred FUNCTION)’
     Matches if the predicate FUNCTION returns non-‘nil’ when called on
     EXPVAL.  The test can be negated with the syntax ‘(pred (not
     FUNCTION))’.  The predicate FUNCTION can have one of the following
     forms:

     function name (a symbol)
          Call the named function with one argument, EXPVAL.

          Example: ‘integerp’

     <...>

          function call with N args
          Call the function (the first element of the function call)
          with N arguments (the other elements) and an additional N+1-th
          argument that is EXPVAL.

          Example: ‘(= 42)’
          ^^^^^^^^^^^^^^^^^ <- this
          In this example, the function is ‘=’, N is one, and the actual
          function call becomes: ‘(= 42 EXPVAL)’.


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