Skip to content

Allow calling fns that are referenced by a fn parameter#47

Merged
taras merged 1 commit intomainfrom
cl/local-function-bind
Dec 15, 2022
Merged

Allow calling fns that are referenced by a fn parameter#47
taras merged 1 commit intomainfrom
cl/local-function-bind

Conversation

@cowboyd
Copy link
Copy Markdown
Member

@cowboyd cowboyd commented Dec 15, 2022

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 -> 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.

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.
@cowboyd cowboyd force-pushed the cl/local-function-bind branch from 60d8baa to e58241d Compare December 15, 2022 18:27
Copy link
Copy Markdown
Member

@taras taras left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@taras taras merged commit 330b54c into main Dec 15, 2022
@taras taras deleted the cl/local-function-bind branch December 15, 2022 20:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants