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]
Found this:
https://groups.google.com/forum/#!searchin/clojure/%22type$20metadata%22%7Csort:date/clojure/LBGsPs2__pQ/oLgx_kgmQxgJ
:tag is applied to source forms to communicate type hints to the
compiler. :type can be used, by convention, to add 'type names' to
runtime data structures that
the type function in clojure.core lets you override the nominal class of an
object with the :type metadata
user=> (type {})
clojure.lang.PersistentArrayMap
user=> (type ^{:type :foo} {})
:foo
On Wed, Oct 24, 2018 at 9:41 AM alex wrote:
> Looks like pre defrecord stuff used in early days to
Looks like pre defrecord stuff used in early days to add "type" to map. Can
still be used if you need "type" on a map without using defrecord.
среда, 24 октября 2018 г., 10:30:14 UTC+3 пользователь Didier написал:
>
> Reviving this thread, as I'd like to kmow if someone can explain the
>
Reviving this thread, as I'd like to kmow if someone can explain the purpose of
the type metadata and what is responsible for adding it?
--
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
On 02/12/2016 01:37 PM, Alan Thompson 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)))
>
>
On 02/12/2016 01:47 PM, Kevin Downey wrote:
> On 02/12/2016 01:37 PM, Alan Thompson 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]