Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement lexical scoping with let expressions #307

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

jamesls
Copy link
Member

@jamesls jamesls commented Mar 23, 2023

See jmespath/jmespath.jep#18 for more details.

NOTE: The JEP is still in the review stage, and is subject to change. This PR won't be merged until the JEP is finalized and approved. I'm sending the PR now in case anyone wants to try it out and experiment with the feature in order to give better feedback.

I'm still going to be testing this more thoroughly, there might be some bugs. I did add the testcases from the JEP as part of this change, and those tests (along with the existing compliance tests) are all passing.

Comment on lines +65 to +67
"comment": "Bindings only visible within expression clause",
"expression": "let $a = 'top-a' in let $a = 'in-a', $b = $a in $b",
"result": "top-a"
Copy link

Choose a reason for hiding this comment

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

Any reason why we don't want the bindings to update as they are being processed/created ?
It could be useful to allow referencing a binding previously declared.

Copy link
Member Author

Choose a reason for hiding this comment

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

This would enable mutually recursive definitions, analogous to letrec in other languages. I'd rather have user defined functions be the mechanism to define that, if that ever ends up happening.

BTW, the best place for questions related to the spec would be on the tracking proposal.

Choose a reason for hiding this comment

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

If variables are set up in the same order they are declared would this be subject to recursive definition ?
I mean $a is assigned first, then $b comes after that and uses $a, etc...

Copy link
Member Author

Choose a reason for hiding this comment

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

I see the comments on the tracking proposal linked, moving the discussion over there.

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.

None yet

2 participants