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: Mon, 8 Jan 2024 15:20:59 +0000

> > Perhaps off-topic, but I think the difficulty
> > of human-parsing pcase sexps can be reduced
> > considerably if each variable bound by the
> > sexp is clearly shown to be just that.
> 
> After reading the example, I see the point you're making.
> I suppose the same issue could apply to cond*.
> Do you think it applies equally to both?
> The only pertinent difference is that cond*
> would use match* or bind* around constructs that can make bindings.

My point about pcase was made originally in
the context of (IMHO) poor examples in the
Elisp manual.

I've only cursorily followed this cond* thread.
My point about pcase not signalling well that
something is a variable binding may not apply
to cond*, if variabless in cond* are always
introduced with a label that signals a binding.
That's akin to the use of an explicit "let" to
signal bindings - not a problem.

> > Even just following a trivial convention,
> > such as prefixing each variable name with,
> > `?', would help.
> 
> Supposing that cond* could benefit from this idea, how can we make
> this idea fit the framework of Emacs Lisp?  `?' has a different
> meaning.  Of course, it does not _have_ to take the form of `?', but
> what could it be?

I don't know.  Some Lisp pattern-matching
contexts have used a cons such as `(? VAR)'
(instead of just `?VAR') to indicate a
variable `VAR'.  And in some such contexts,
the cons can even be updated destructively
to unify (logic programming) or instantiate.

My guess is that if you use a label such as
`match*' or `bind*', and if in that context
it's clear enough which things are the vars,
then you don't also need a syntax convention
(or enforcement) such as a `?' prefix.

So my comment about this may be off-topic in
a strict sense for this thread.  In a more
general way it might still be relevant or
helpful.

I really do guess that much of the bother
people have with pcase and learning its
syntax comes from _vars not being obvious_.

For lispers used to backquote syntax I
think variables not signaling themselves
is likely to be more of an obstacle than
the use of backquote.

A third obstacle, IMO, is the mixing of
variable-binding constructs with control
(conditional) constructs.  That's also
the case for `loop' and even things like
`if-let'.  But `if-let' & compagnie are
simple, compared to `loop' and `pcase'.

Among (1) unobvious var bindings, (2)
backquote syntax, and (3) mixing of
control structure with pattern-matching
/ var-binding, the degree to which each
presents an obstacle to understanding/
reading/learning is debatable.

reply via email to

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