How does argument passing work in Clojure? -
i know in java, if pass object method argument, method let argument variable point same object rather making duplicate. how in clojure? example:
(defn print-from-reader [rdr] (print (.read rdr))) (...inside code... (with-open [rdr (reader file)] (print-from-rader rdr)))
does print-from-reader make copy of rdr in memory when rdr passed in, or it's pointing same rdr that's created with-open binding?
and there way check if 2 clojure instances pointing same memory?
sorry bad terms such "pointing to" , "instances", newbie in clojure , still learning it. :-)
clojure pass-by-value java. think of as, references passed value. isn't stretch clojure work this, scheme , common lisp behave same way.
you can test whether 2 references point same memory identical?
:
(identical? x y)
tests if 2 arguments same object
Comments
Post a Comment