FAQ
Subject: = in ClojureScript differs from Clojure API for arities other
than 2

Using ClojureScript f4c0de502c92ce710da923888d672f22213b902c (checked
out on Thu Jan 19 2012)
=> (= 1)
false ;; incorrect

=> (= 1 1)
true

=> (= 1 1 2)
true ;; incorrect

=> (= 1 1 1)
true ;; correct, but by accident

In Clojure and according to Clojure's API = is defined for all arities
[1,2]
=> (= 1)
true

=> (= 1 1)
true

=> (= 1 1 2)
false

The source of this bug is that = is only implemented in ClojureScript
for the 2 arity [3]. Combined with the javascript behaviour for
superfluous arguments this leads to these unfortunate results.
Implementing = for multi arities in ClojureScript by following the
Clojure implementation should fix this. See for example the <
predicate in ClojureScript [4].

My apologies for not using the bug tracker and not supplying a patch.
I am not yet familiar with those systems.

-Gijs

[1] = API - http://clojure.github.com/clojure/clojure.core-api.html#clojure.core/=
[2] = in clj - https://github.com/clojure/clojure/blob/master/src/clj/clojure/core.clj#L719
[3] = in cljs - https://github.com/clojure/clojurescript/blob/master/src/cljs/cljs/core.cljs#L180
[4] < in cljs as an example of a multi-arity predicate -
https://github.com/clojure/clojurescript/blob/master/src/cljs/cljs/core.cljs#L801

--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to
clojure+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Search Discussions

  • David Nolen at Jan 19, 2012 at 4:53 pm

    On Thu, Jan 19, 2012 at 11:18 AM, Gijs S. wrote:

    Subject: = in ClojureScript differs from Clojure API for arities other
    than 2

    Using ClojureScript f4c0de502c92ce710da923888d672f22213b902c (checked
    out on Thu Jan 19 2012)
    => (= 1)
    false ;; incorrect

    => (= 1 1)
    true

    => (= 1 1 2)
    true ;; incorrect

    => (= 1 1 1)
    true ;; correct, but by accident

    In Clojure and according to Clojure's API = is defined for all arities
    [1,2]
    => (= 1)
    true

    => (= 1 1)
    true

    => (= 1 1 2)
    false

    The source of this bug is that = is only implemented in ClojureScript
    for the 2 arity [3]. Combined with the javascript behaviour for
    superfluous arguments this leads to these unfortunate results.
    Implementing = for multi arities in ClojureScript by following the
    Clojure implementation should fix this. See for example the <
    predicate in ClojureScript [4].

    My apologies for not using the bug tracker and not supplying a patch.
    I am not yet familiar with those systems.

    -Gijs
    Open a ticket with this information in JIRA please. It would be nice to get
    a set of benchmarks with the patch as well. = is a pretty critical fn and
    supporting multiple arities is a big performance hit.

    David

    --
    You received this message because you are subscribed to the Google
    Groups "Clojure" group.
    To post to this group, send email to clojure@googlegroups.com
    Note that posts from new members are moderated - please be patient with your first post.
    To unsubscribe from this group, send email to
    clojure+unsubscribe@googlegroups.com
    For more options, visit this group at
    http://groups.google.com/group/clojure?hl=en

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupclojure @
categoriesclojure
postedJan 19, '12 at 4:18p
activeJan 19, '12 at 4:53p
posts2
users2
websiteclojure.org
irc#clojure

2 users in discussion

David Nolen: 1 post Gijs S.: 1 post

People

Translate

site design / logo © 2022 Grokbase