Giter Club home page Giter Club logo

Comments (6)

borkdude avatar borkdude commented on May 24, 2024 1

Since CLJS accepts it and I haven't heard anyone complain about that, I think it's better to just leave it since then the SCI code can remain the same for both implementations.

from babashka.

borkdude avatar borkdude commented on May 24, 2024

ClojureScript also accepts (let [a 1, b 1] #{a b}). I would consider this undefined behavior or an incidental implementation detail.

from babashka.

borkdude avatar borkdude commented on May 24, 2024

Ah wait:

user=> (defn foo [a b] #{a b})
#'user/foo
user=> (foo 1 1)
Execution error (IllegalArgumentException) at user/foo (REPL:1).
Duplicate key: 1

from babashka.

borkdude avatar borkdude commented on May 24, 2024

It seems JVM Clojure has a createWithCheck mechanism which is used for literals:

https://github.com/search?q=repo%3Aclojure%2Fclojure%20createWithCheck&type=code

from babashka.

borkdude avatar borkdude commented on May 24, 2024

Still I think the question should be asked: why is this important, exactly? I never had a situation myself where leaving the check off would have made a big difference.

from babashka.

brdloush avatar brdloush commented on May 24, 2024

I agree it's probably "incidental implementation". I simply just realized that there's this strange difference between clj and babashka and though it might be nice to at be aware know about it, that's all.

Personally I never even realized that set initialization using #{} form actually throws in clojure. Instinctively, I'd expect it to behave similar to into #{}, i.e. duplicities get silently ignored. Because, well.. why not.

When I think about it, the fact that the form using values #{1 2 3 1} throws might make sense. If the expression is such a simple static literal, then the compile error might make come handy (in a way it can be thought as a kind of late compile-time "linter")

I agree I wouldn't "fix" this discrepancy in behavior as there's probably no "agreed contract" regarding how all this should "officially" behave. Let's close this issue.

from babashka.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.