I'm pretty new to Clojure, so please bear with me if this is obvious for 
some reason. Maybe the answer is out there and I've been looking in the 
wrong place.

I'm seeing some strange behavior losing type information when using eval in 
certain circumstances. Here is an example:

Eval-ing a Timestamp is still a Timestamp:

(def my-timestamp (clj-time.coerce/to-timestamp (java.util.Date.)))
=> #'user/my-timestamp
(type my-timestamp)
=> java.sql.Timestamp
(eval my-timestamp)
=> #inst "2015-08-28T15:03:10.557000000-00:00"
(type (eval my-timestamp))
=> java.sql.Timestamp

Using the Timestamp as a hash value also works as expected:

(def timestamp-holder {:a my-timestamp})
=> #'user/timestamp-holder
(type (:a timestamp-holder))
=> java.sql.Timestamp
(eval (:a timestamp-holder))
=> #inst "2015-08-28T15:03:10.557000000-00:00"
(type (eval (:a timestamp-holder)))
=> java.sql.Timestamp


But now instead eval the hash map and its type gets more generic:

(eval timestamp-holder)
=> {:a #inst "2015-08-28T15:03:10.557-00:00"}
(type (:a (eval timestamp-holder)))
=> java.util.Date

Is this expected behavior?

-- 
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+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to