On Mar 9, 2:19 am, Mark Engelberg <mark.engelb...@gmail.com> wrote:
> On Sun, Mar 8, 2009 at 10:44 PM, mikel <mev...@mac.com> wrote:
> > Clojure doesn't have to provide these facilities (though I wouldn't
> > mind if it did); it just needs to stay out of my way when I decide I
> > need to add them.
>
> Yeah, as much as I like maps, I feel like there are several common
> uses cases for maps that require more work in Clojure than other
> languages.  The most obvious example is tagged structs.  In Clojure,
> you need to do a defstruct, and then make your own custom constructor
> that adds the tag, possibly another custom constructor that emulates
> struct-map but adds the tag, and possibly a predicate that tests for
> the tag.
>
> I particularly like the way the Mozart language makes tagged structs
> (they call them records) one of the core data structures that the
> language is built around.
> See section 3.6 athttp://www.mozart-oz.org/home/doc/tutorial/node3.html
>
> I can see why the existing system is more flexible (you can have more
> than one tag, or no tag, or make the tag part of the metadata, or use
> different labels for the tag other than :tag or :type), but I keep
> feeling like 90% of the time I'd be happy to just use a standard
> tagged struct.  The good news is that it's easy to write a macro to do
> all the boilerplate.  The bad news is that everyone will write
> different macros that tag these structures in different ways, and it's
> not clear to me how well code written based on different tagging
> standards will coexist.

I understand. I've pushed hard not to have the language dictate an
object system, and especially not to tie important capabilities like
polymorphic dispatch and hierarchy to a specific type system. That
said, I don't want to make the common cases hard or confusing.

There is now a supported convention for tagging, the :type metadata,
and the type function which returns either the :type meta or the Class
if none. This should provide a common way to handle the basic case - a
single type tag. These :type tags can participate in the hierarchy
system and thus provide a lot of flexibility.

I'd like to see what people do with that and drive any further common
utilities from shared needs.

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

Reply via email to