Repository navigation
Partial application of callables and lambdas without declared arity (#83) - #133
Merged
Merged
Conversation
- JLambda (Fn0..Fn8) reports its number of declared parameters, which JFunctions created via Jsonata.function(...) keep - arity unknown (callable / FnVarArgs without signature): use the number of args supplied at the partial application - implement the JS "typeof proc === 'function'" branch: lambdas bound via Frame.bind can be partially applied Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
These need the arity of a JFunctionCallable without signature (#83). Also update the PartialTest comments: the cases are no longer gaps. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Third of three PRs split out of #130. Builds on #131 and #132 (both merged). With this one, everything in #130 is covered and #130 can be closed.
Fixes #83
Why
#132 made native partial application work like jsonata-js, but it gets the arity of a
JFunctiononly from its implementingMethodor its signature. jsonata-js takes the parameters of a native function fromfunc.toString(). Custom functions registered without a signature, andFn*lambdas, had no arity, so$add(1, 2) ~> $add(?, 3)failed for them.Arity of Java functions
JFunction.getNumberOfArgs()now uses, in order:MethodJLambda(Fn0–Fn8→ 0–8), kept by theJsonata.function(...)factoriesJFunctionCallableorFnVarArgswithout signature): the number of args supplied at the partial application, e.g.$add(?, 3)→ 2. This is the only deviation from JS: extra args are not dropped and missing ones are not bound.It also implements the JS
typeof proc === 'function'branch inpartialApply, soFn*lambdas bound viaFrame.bind(...)can be partially applied (before this they failed with T1008).API note
JLambdawas an empty marker interface. It now declaresgetJFunctionCallable()and a defaultgetNumberOfArgs(). AllFn*types implement both, but a class implementingJLambdadirectly would need to addgetJFunctionCallable().Testing
PartialTest: 3 new cases, for a callable without signature, anFn*factory without signature, and a lambda bound viaFrame.bind.OldPrsTest: the two Issues-83: Custom function pipe error #85 pipe cases ($multiply(3) ~> $multiply(?, 2),$add(1, 2) ~> $add(?, 3)) that were held back from Align partial application of native functions with jsonata-js (#95) #132.-Dmaven.compiler.release=11.🤖 Generated with Claude Code