The Scopes Compiler Infrastructure
This file is distributed under the MIT License.
See LICENSE.md for details.
chaining provides the `-->` operator, which allows the nesting of
expressions by chaining them in a sequence.
""""Expands a processing chain into nested expressions so that each expression
is passed as a tailing argument to the following expression.
`__` can be used as a placeholder token to position the previous expression.
h 2 __
sugar --> (expr ...)
fn placeholder? (elem)
(('typeof elem) == Symbol) and (elem as Symbol == '__)
fold (outp = expr) for expr in ...
let anchor = ('anchor expr)
match ('typeof expr)
let prev-outp = outp
let expr = (expr as list)
let outp found =
fold (outp found = '() false) for elem in expr
if (placeholder? elem)
error@ ('anchor elem) "while expanding expression" "duplicate placeholder token"
_ (cons prev-outp outp) true
_ (cons elem outp) found
`[(.. expr (list prev-outp))]
`[(list expr outp)]