emacs-devel
[Top][All Lists]
Advanced

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

RE: [External] : Re: cond*


From: Drew Adams
Subject: RE: [External] : Re: cond*
Date: Tue, 19 Dec 2023 15:53:47 +0000

Apologies for not taking much time to check what
you've suggested in more detail.  If this reply
doesn't help, please just ignore it.

> It would be possible to indicate fall-through clauses
> by making them start with t.  For instance,
> 
>   ((match* PATTERN DATA))
> 
> would become
> 
>   (t (match* PATTERN DATA))
> 
> With this change, whether a clause falls through would have nothing to
> do with how many elements it has, only with whether its first element
> is t.

Noticing whether a clause has more than one sexp
isn't the best approach, I think, as I mentioned.

But adding `t' that way doesn't help either, IMO.
In fact, it can make things worse.

> Note that this change in rules would make no change
> in the interpretation of a final clause that starts with t.

Yes, and that's a source of confusion.  It looks
too much like a clause whose condition is always
true and whose _action_ (and the `cond*' return
value) is the effect (and the value) of that
`match*' sexp.

> Please send me feedback about this proposed change.  If you like it,
> if you dislike it, or if you think it makes little difference, I would
> like to hear that from you.

Thanks for trying to address the problem I raised
(to more easily distinguish no-action/return
clauses from action/return clauses).

Initially you had a no-action clause in this form:
(match* PATTERN DATA).  I actually (mis)thought
the initial form was what you _next_ proposed:
((match* PATTERN DATA)).

I also (mis)thought that action clauses, that is,
clauses whose return value can be the return value
of the `cond*', had a set of surrounding parens,
just as in `cond'.

And I was then thinking about suggesting that you
change a no-action clause to just what you in fact
had proposed initially (which I missed).  Then,
action clauses would continue to have surrounding
parens (just like a `cond' clause) and no-action
clauses would not - easier to see the difference.

A no-action clause affects all subsequent clauses.

So another suggestion was to be (and still could
be) to move a no-action sexp inside the parens
of the next action clause, instead of letting it
be a clause on its own.  That way, _all_ clauses
would be action clauses (i.e., could provide the
`cond*'s return value).  They just might have one
or more no-action sexps at their beginning.

E.g., instead of this:

(:match ...)          ; no-action sexp as a clause
(CONDITION . ACTIONS) ; action clause

You'd have this:

((:match ...) CONDITION . ACTIONS)

(Consecutive no-action sexps would be included in
the first action clause that follows them.)

I'd still suggest that, except that I have this
question: Is there perhaps such a case as having
a no-action sexp whose bindings are to be _local_
to the following action clause, i.e., they would
be undone for following clauses?

If that's the case, then a natural way to express
that would be to put the no-action sexp inside
the action clause that it affects.  IOW, the form
I suggested above for _all_ no-action sexps.

In that case, there'd be no way to distinguish a
no-action (e.g. binding) sexp that affects _all_
subsequent action clauses from one that's local to
just the next action clause.

So far, I don't think I've noticed any locality
of binding sexps - e.g., bindings that would be
undone for clauses following the immediately next
one.  If there won't be any clause-local no-action
sexps then the suggestion above might work.

To repeat the suggestion:

Require each clause to have a tail of
(CONDITION . ACTIONS):

  ([NO-ACTION-SEXP]* CONDITION . ACTIONS)

This means that a NO-ACTION-SEXP cannot appear on
its own, as a clause.  It's part of some clause
that has an action/return value.  Each clause can
end the `cond*' and provide its return value.

And, as previously, a NO-ACTION-SEXP affects the
clause it belongs to, _and_ subsequent ones.
(I.e., no possibility of a no-action sexp whose
effect is only local to a given clause.)

Again, apologies if I've missed something.  The
main point here is to not have no-action sexps
as clauses: the return value of any clause can
be the `cond*'s return value.

And again, by "no-action sexp" I just mean a
sexp that only matches/binds and whose result
can't possibly be the `cond*'s return value.

With this suggestion there's no "fall through".
Each no-action sexp belongs to some clause, and
each clause can provide the `cond*' return value.

Does this make sense?

reply via email to

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