Open
Description
jbind
is quite useful already, but it is somewhat hard-coded in functionality. Allowing arbitrary predicates is probably the biggest customization that can happen to it, so that one can do:
(njson:jbind #(1 #'evenp 3 (lambda (n) (= n 4)) five)
five)
And make sure that an array like #(1 8 3 4 X ...)
passes the check and returns the provided X.
Problematic moment is: function
and lambda
forms conflict with optional value parsing due to being symbol conses.
- So it's unclear what
(function foo)
means: a predicate reference or optional binding forfunction
variable. lambda
is easier to parse and harder to miss due to arglist presence, but JBIND/JMATCH: better optional value syntax (default values? nested destructuring?) #8 can change that too.quote
d symbols don't work for predicates either: they are symbol-lead conses too.
So it's either hard-coding the rules for function
, lambda
, quote
etc. (which is really unreliable), or coming up with a new syntax. Risking too much bloat here...