Allow calling fns that are referenced by a fn parameter#47
Merged
Conversation
When converting a map into a function call, we were requiring that the function be defined at the time of binding. this works module imports or global functions, but what if the function reference is introduced into a scope via a function parameter? We need to leave it as a reference and then look up the reference when we bind the function body before evaluation of the function. This changes the name of the `FnCall -> FnCallContext` and then the PSValue of type `fncall` records only the fact of the function call itself, and does not create an environment. This is better in that the `FNCall` is just data. Note that this breaks the `$do/$let` statement... as you can now not introduce a `$let` statement after `$do`. You either need to but `$let` before, or not have it at all.
60d8baa to
e58241d
Compare
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.
Motivation
When converting a map into a function call, we were requiring that the function be defined at the time of binding. this works module imports or global functions, but what if the function reference is introduced into a scope via a function parameter? We need to leave it as a reference and then look up the reference when we bind the function body before evaluation of the function.
Approach
This changes the name of the
FnCall -> FnCallContextand then the PSValue of typefncallrecords only the fact of the function call itself, and does not create an environment. This is better in that theFNCallis just data.Note that this breaks the
$do/$letstatement... as you can now not introduce a$letstatement after$do. You either need to but$letbefore, or not have it at all.