Fork me on GitHub
#beginners
<
2017-04-30
>
matan07:04:35

aiming for a symbol's name with str, what does the part after the @ actually describe? > [email protected]

rauh07:04:25

@matan Not a symbol but a Java object. It's the memory address of the object

matan08:04:30

@rauh thanks, I wonder which object would that be, when this is the str output for a clojure function

rauh08:04:29

@matan It's the class object representing the function (a function is implemented as a method of a class). A symbol referring to a var is automatically dereferenced to the actual object, if you dont want that you'd have to use (var the-fn) to get the var object

noisesmith09:04:02

rauh: just to nitpick for a moment, a clojure function is implemented as an object (which is why we can use functions as arguments but not methods). That function implements a few methods that call the actual code in our function body, yes.

rauh09:04:51

Yeah, the "class object" was wrong. Good point.

matan08:04:01

so each fn gets its own dedicated object in the runtime?

rauh09:04:03

@matan each fn get's compiled to a class + method. So when you take the value of a function you'll get the object back. See: https://clojure.org/reference/java_interop#_calling_clojure_from_java

matan09:04:19

:thumbsup: