4 ms·
> (...) there would be no effort to switch away from pcase, however, as it is "to be considered a matter of stylistic preference". I'm sometimes glad that the
by phoe-krk 3y ago
> (...) there would be no effort to switch away from pcase, however, as it is "to be considered a matter of stylistic preference".
I'm sometimes glad that the CL standard is frozen.
Sarcasm aside, this is literally https://xkcd.com/927/ https://xkcd.com/927/.
Sarcasm aside for real this time, getting this sort of binding mechanism in a COND-like form is unusual. This effectively means that a programmer needs to inspect all previous COND* forms, instead of relying on lexical scope AND indentation as they normally would, to see where new bindings are made. This is like Common Lisp's LOOP, but even there bindings are only allowed at the beginning of the loop, before any iteration clauses.
- 48864w6ui 3y agoIt may be unusual, but binding is the point of pattern matching. Expressions take a bunch of bindings and give a value; patterns take a value and give a bunch of bindings.
- deleted 3y ago[deleted]
- hibbelig 3y agoI think you need to go down the conditionals in order anyway, if cond* it’s like cond in that it evaluates the conditions top to bottom. So keeping track of “all the bindings so far” makes intuitive sense to me. I also see a parallel to if/else if/else cascades. You can “break” and else if leg into … else { zzz; if (…) … } and then you can declare new variables at the zzz spot that are then available for the rest of the cascade. I don’t know much about pcase and cond* so I can’t speak to the more general point. I just wanted to mention one specific aspect. I miss emacs but as a Java developer what can you do…
- lispm 3y agoEvaluating conditions don't introduce bindings in COND. In Lisp typically bindings are only introduced in forms together with scope: DEFUN, LET, and a lot of other constructs. Binding construct which affect forms outside its syntactic scope is rare in Lisp. In Scheme there is sometimes: (define (foo) (define a 10) (+ a 42)) But even there all the embedded "define"s, by standard, need to be at the top of the body, directly at the start.
- alwaysbeconsing 3y agoAgree, it is Curse of Lisp mixed in NIH syndrome. Syntax of cond* is no more straightforward than that of pcase. As was pointed out on mailing list. Awkward decision by maintainers to keep both into core.