clojerl / clojerl

Clojure for the Erlang VM (unofficial)

Home Page:http://try.clojerl.online/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Symbols in REPL are identical

arpunk opened this issue · comments

Describe the bug

Clojure symbols are not interned, i.e: it creates a new symbol for each occurrence, but in Clojerl they seem to be identical.

To Reproduce

clje.user=> (= 'foo 'foo)
true
clje.user=> (identical? 'foo 'foo)
true

Expected behavior

user=> (= 'foo 'foo)
true
user=> (identical? 'foo 'foo)
false

Actual behavior

Symbols are identical.

Context

clojerl version (tag/sha): 0.7.1-2060.0fcf2de

Is this a known difference from Clojure?

Hi @arpunk 👋 !

This is a known difference. identical? in Clojure JVM (which "Tests if 2 arguments are the same object ") ends up using the JVM operator == through the clojure.lang.Util/identical method:

static public boolean identical(Object k1, Object k2){	
     return k1 == k2;
}

There are no objects in the BEAM, there are only values, so identical? ends up being the same as =.

Do you think it would be better and less confusing if we didn't have identical? at all available in Clojerl?

Hey @jfacorro, hello!

I think it's less confusing in Clojerl as I'd expect symbols 'a and 'a to be identical but I'm just starting out with Clojure so I was just wondering about the difference and your explanation makes sense!

I'm glad to hear that it makes sense 😊

I will close this issue if that's OK with you. Please feel free to reopen it if you have any further questions.