|
| From: | JD Smith |
| Subject: | Re: Code for cond* - cond*-match, cond*-subpat and backtrack-aliases |
| Date: | Mon, 29 Jan 2024 07:16:32 -0500 |
In a separate subthread (and offline) I've been discussing a simple `cond-let', envisioned as part of the if/when-let family (it has no pattern matching capabilities). It does, as you'd expect, offer local bindings for each clause.
Here is the new version. I made a test framework for it ...
I wonder why (bind*) evaluates only its first value to determine if the binding condition is true? We already have macros which evaluate the "truth of a set of bindings": the members of the if-let family. And they
I would personally find this behavior for variables bound locally within clauses easier to remember and more useful. Users will already be familiar with it (from if-let), and it supports plain (VALUE) "bindings" for when you'd like to mix actual variable bindings and other tests in a given clause's CONDITION. Attached is a simple cond-let design (again, just a simple extension of if/when-let, no pattern matching). You notice that rather than using any particular keyword sigil like :let or bind*, it simply checks if the CONDITION of a clause is a list-of-lists, in which case it is interpreted as a binding spec. The only small addition to if/when-let's binding handling is for plain (CONDITION-BINDING-SPEC) clauses; in that case, if all binding values are non-nil, the final value is returned from cond-let. |
cond-let.el
Description: Binary data
| [Prev in Thread] | Current Thread | [Next in Thread] |