3 ms·
TXR Lisp has a form of unhinged let in the "opip syntax" that underlies all of its threading macros. https://www.nongnu.org/txr/txr-manpage.html#S-F2CAF1CB htt
by kazinator 3y ago
TXR Lisp has a form of unhinged let in the "opip syntax" that underlies all of its threading macros.
https://www.nongnu.org/txr/txr-manpage.html#S-F2CAF1CB https://www.nongnu.org/txr/txr-manpage.html#S-F2CAF1CB
For instance
(flow 1
(+ 2)
(let x) ;; x is 3 now
(+ 3)
(let y) ;; y is 6
(+ 4) ;; pipeline value is 10 now
(+ x y)) ;; 19 returned: (+ 3 6 10)
There is a (let (var1 init1) (var2 init2) ...) syntax supported also. Both these variants act as pass-through pipe elements: they bind variables that are in scope of the rest of the pipe.
However, if you use the normal (let ((var init) ...) ...) syntax, then that is not special any more; it is just the regular let being threaded, like any other operator. It does not bind variables visible to the rest of the pipe.
Outside of this, there are only let and let* which resemble the Common Lisp ones.
Note that this construct makes sense even in pure code; it was not introduced for the sake of inserting side effects between variable definitions, but for capturing the output at specific points of the pipe, binding it to a name.
- pfdietz 3y agoThere's a de facto standard macro for Common Lisp that does something similar, called nest. It's in UIOP.