emacs-devel
[Top][All Lists]
Advanced

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

Re: Code for cond*


From: Stefan Monnier
Subject: Re: Code for cond*
Date: Sat, 27 Jan 2024 22:06:09 -0500
User-agent: Gnus/5.13 (Gnus v5.13)

>   > >        ;; 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*.

I like the feature (especially since it's how we introduce bindings
that scope over the rest of the branches), but I find the syntax
too inconspicuous.

I'd rather either have some "magic keyword" indicate "this is not
a branch", or maybe use [...] instead of (...)?

>   > >        ;; 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,

I didn't suggest to call it `let*`.
`pcase-let` is not called `let` and neither is `cl-macrolet` :-)

Having `let` in the name would make a lot more sense.

Also, if

    (FORM)

means "Execute FORM, and ignore its value", then the above

    ((bind* (x foobar) y z (foo 5) a))

would collide with an actual `bind*` function or macro.

That's also part of the reason why I considered using

    (:let ...)

when I considered adding bindings to `cond`.

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

But there are macros and functions with `*` at the end of their names,
so it doesn't make it clear to me at all.

In my view of the Lisp world, when you talk about symbols that represent
special syntax that are only given a meaning by where they're used,
I think of keywords instead (hence my use of `:let`), which cannot be
used as variables and by convention are never used as functions either.

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

I do like such a uniform rule.  I just think it needs to be more visible
than just the absence of something before the next close paren.


        Stefan




reply via email to

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