emacs-devel
[Top][All Lists]
Advanced

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

Re: Code for cond*


From: Richard Stallman
Subject: Re: Code for cond*
Date: Thu, 25 Jan 2024 23:30:23 -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. ]]]

  > >        ;; Execute FORM, and ignore its value
  > >        ;; (except if this is the last clause).
  > >        (FORM)

  > YAGNI.

If this were a special feature, it might not be worth having.

But it is not a special feature.  It is a special case of the general
rule that a clause with one element is a non-exit clause.

I think it will sometimes be useful to execute something unconditionally
in the middle of a cond*.  

  > >        ;; Variables to bind, as in let*, around the rest
  > >        ;; of the cond*.
  > >        ((bind* (x foobar) y z (foo 5) a))
  > >        ;; Bindings continue in effect for the whole cond* construct.

  > This is one of the functionality missing from `cond`, so I'm rather
  > favorable, but:
  > - why `bind*` when the rest of ELisp uses `let*` in the names of all
  >   related constructs?

`let*' is a Lisp function, and that is reflected in the syntax for using it.
Calling this `let*' would be misleading, because this is not a Lisp function
and can't have syntax similar to that of `let*'.  There is no way that
it could fit into cond* and have syntax like `let*'.

So better it have a different name.

  > - Why the double parens?

They make this a clause with only one element -- in other words, a
no-exit clause.

It would be possible to use the syntax

   (bind* BINDINGS...)

and say that `bind*' is a syntactic special case.
I think that having the no-exit rule is simpler overall.

However, I see no way to do this for `match*'.  It will be
used in both exiting and non-exit clauses.  I don't see
any other simple syntax to use to distinguish those two cases.

Do you have a suggestion?



  > - Why `*`?

I put * at the end of the names `bind*' and `match*' to go with
`cond*' and thus make it easier to recall how they go together.  Also
to make it clear that they are special syntax, not Lisp functions, so
their uses can't be understood like function calls.

To omit that * would be straightforward, but I think those reasons
are valid for keeping it.

  > - I'm not happy about using the same construct for "bindings
  >   for this clause" and "bindings for subsequent clauses".

The alternative to having a uniform rule to distinguish a non-exit
clause from an exiting clause is to specify four special symbols, one
for each combination (matching vs binding, one clause vs remaining
clauses), like this:

              MATCH     BIND

ONE CLAUSE    match*    bind*

ALL CLAUSES   match**   bind**

I am not wedded to those four names.

If people who like cond* would prefer it with this change, plesae let
me know.

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