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

evaluation order of meta value #659

Closed
erdos opened this issue Jan 11, 2022 · 1 comment
Closed

evaluation order of meta value #659

erdos opened this issue Jan 11, 2022 · 1 comment

Comments

@erdos
Copy link
Contributor

erdos commented Jan 11, 2022

version: Babashka 0.7.3 with sci 0.2.8
platform: Linux binary

problem:

When a map/set/vector expression has metadata map attached to it, JVM Clojure evaluates value first and metadata map second. In Babashka, the order is the opposite.

The evaluation order of expression and its meta map is inconsistent to the order in Clojure. The Clojure spec is not very specific about it, however, such minor difference may still have effect on portability of Clojure codebase into Babashka.

repro:

(with-out-str ^{(print 2) (print 3)} {:b (print 1)})

expected behavior:

In Clojure 1.10.3, it returns "123".

In Babashka, result is "231". 123 would be preferred/expected.

solution:

I think it can be addressed for maps by changing evaluation order in

(defn eval-map

(I have not yet found the location for solving it for sets and vectors.) Can I go ahead with a PR of the change?

@borkdude
Copy link
Collaborator

Yes, thank you.

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

No branches or pull requests

2 participants