On 02.03.2009, at 01:50, Rich Hickey wrote:

> I was wondering if you considered using maps or struct-maps for this.
> One of my pet peeves with algebraic data types is the unnamed,
> positional nature of the components/fields. It always bothers me you
> have to rename the fields in every pattern match, skip fields with _
> etc.


There is something similar on my list of ideas for future extensions  
of the algebraic data type module: optional keywords to name the  
parameters of the constructors, which could then also be used for  
matching in templates. Each component could then be referred to  
either by its position or by its keyword. The model I have in mind is  
function parameter passing in Python. The concrete representation  
would still be vectors, probably, but no one should rely on the  
concrete representation anyway. At the moment I use vectors because  
template matching expands to code that uses nth for element access,  
which is fastest for vectors.

I wouldn't like to have only named elements, because for constructors  
with few arguments (one, at the extreme), this would be needlessly  
verbose. Consider a very simple algebraic data type like Haskell's  
maybe:

        (deftype maybe
          nothing
          (just x))

Now that I re-think about this, it would make sense not to have  
additional keywords as names, but use the constructor argument names  
directly. All that would be required in addition to the current  
mechanisms is an additional name-based template syntax.

BTW, another idea I have for future extensions is types with lazy  
fields, with the constructors defined as macros and the component  
values stored in delay objects. That would allow the construction of  
lots of lazy data structures.

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