On Apr 14, 11:11 am, Stuart Sierra <the.stuart.sie...@gmail.com>
wrote:
> On Apr 13, 9:12 pm, Rich Hickey <richhic...@gmail.com> wrote:
>
> > :tagis applied to source forms to communicatetypehints to the
> > compiler. :typecan be used, by convention, to add 'typenames' to
> > runtime data structures that support metadata. Thetypefunction will
> > return the :typemetadata if present, else the class, making it a
> > handy dispatch function. Neither :tagnor :typeare used directly by
> > isa?
>
> What about using maps as structured records, with a special key for
> the "class". Some people use :tagas the "class" key, some
> use :type. Should this be stored in metadata, rather than in the map
> itself?
>
That's an open question. There are many reasons it is better as a
normal key. The arguments for being metadata are:
It allows for things other than maps to have 'types'
It doesn't impact equality
It doesn't appear as a 'field' to other code
Advantages to having it be a map key/attribute:
That's really what type/class is, another attribute, thus only things
that have attributes (maps) should have it.
It will impact equality*
It will appear as a 'field' to other code, in particular things like
Datalog
* - a key issue here is that only exact type equality is supported.
I'm leaning towards the latter camp as I see more use cases.
Rich
--~--~---------~--~----~------------~-------~--~----~
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
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
-~----------~----~----~----~------~----~------~--~---