Fix issue #645: Implement binding macro#646
Closed
jonasseglare wants to merge 1 commit intosquint-cljs:mainfrom
Closed
Fix issue #645: Implement binding macro#646jonasseglare wants to merge 1 commit intosquint-cljs:mainfrom
jonasseglare wants to merge 1 commit intosquint-cljs:mainfrom
Conversation
jonasseglare
commented
Apr 4, 2025
| (is (= 4 (jsv! "(def ^:dynamic a 3) (binding [a 4] a)"))) | ||
| (is (= 3 (jsv! "(def ^:dynamic a 3) (binding [a 4] a) a"))) | ||
| (is (eq #js [#js [3 4] #js [100 10] #js [3 4]] (jsv! "(def ^:dynamic a 3) (def ^:dynamic b 4) [[a b] (binding [a 100 b 10] [a b]) [a b]]"))) | ||
| (is (eq #js [500 119] (jsv! "(def ^:dynamic x 119) (def y (try (binding [x 120] (throw (js/Error \"Failed.\")) x) (catch js/Error _ 500))) [y x]"))) |
Contributor
Author
There was a problem hiding this comment.
I included ^:dynamic here even if it is not needed to make the code look like Clojure. But maybe I should simply remove it.
Member
|
A big caveat with binding and ES6 modules is that it only works within one and the same module, since you can't alter "vars" from other modules. This is why I haven't included it in squint (yet). |
Contributor
Author
|
Thanks! I will close the PR now since this is not supported. |
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.
This PR implements a macro called
bindingto dynamically bind variables.Fixes issue #645 .
Please answer the following questions and leave the below in as part of your PR.
This PR corresponds to an issue with a clear problem statement.
This PR contains a test to prevent against future regressions
I have updated the CHANGELOG.md file with a description of the addressed issue.