On 22.01.2009, at 10:51, Konrad Hinsen wrote:

> At the end of this message is a simple illustration of what can be
> done with these changes. Any feedback is welcome of course!

Maybe I should reply immediately to some objections I expect to come:

1) Why create a secondary type system around structs? Why not  
something more general?

Many languages have type system grown out of structures, e.g. C++, or  
Scheme. It works pretty well. I'd happily propose something more  
general if I had a great idea.

In the meantime, there is a real need for something like a type  
system for use with multimethods, as the topic comes up repeatedly on  
this group. It looks strange to see a language in which it is easy to  
define a type hierarchy (using derive) but in which putting the type  
label on an object is a pain.

2) Using metadata is more general.

A bit, but metadata is limited to collections as well. Moreover, it  
is used for many different applications, which creates the risk of  
conflicts. Finally, it is invisible (not part of the printed  
representation) and not used in comparisons etc. It is not considered  
part of the value of a data item, whereas type information normally  
*is* part of the value, even an important one.

3) Structmaps are just an optimized implementation of maps.

That's what they are now, but that doesn't mean they can't evolve  
into something else. For structs to become an "official" type system,  
some more changes would be useful:
- Structure basis objects should have a printed representation that  
includes the name given in defstruct (or nil for an anonymous one  
created by create-struct)
- Structure basis objects could acquire some methods, e.g. for  
obtaining the keys.

Konrad.


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