I think the main intention of type is to be used as a more generic version
of class, that lets clojure data participate alongside java objects etc
with multi-methods etc.

i.e.

(defmulti foo type)

(defmethod foo java.lang.String [x]
  :string-dispatched)

(defmethod foo :my-clojure-type [x]
  :my-clojure-type-dispatched)

(foo ^{:type :my-clojure-type} {:blah :blah}) ;; =>
:my-clojure-type-dispatched

derive et al also let you use keywords to augment java class hierarchies
with new types, provide multiple inheritance and priorities with
prefer-method etc.

R.

On Fri, 12 Feb 2016 at 21:37, Alan Thompson <clooj...@gmail.com> wrote:

> Hey - Just saw something on the clojure.core/type function:
>
>
>
> (defn type
> "Returns the :type metadata of x, or its Class if none"
> {:added "1.0"
> :static true}
> [x]
> (or (get (meta x) :type) (class x)))
>
>
> I have never seen this before, and it appears the :type metadata is not
> used in the clojure.core source code itself.  Is this ever used for
> anything or is it just a vestigial remnant from long ago?
>
> Alan
>
> --
> 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.
>

-- 
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