Konrad Hinsen wrote:
> On Mar 12, 2009, at 10:59, Jeff Rose wrote:
> 
>>> My main conclusion is that Clojure's system is a lot more flexible
>>> but also a lot more fragile. Any function can modify data of any
>>> "type" (as defined by metadata), even without being aware of this.
>> Modifying type tags without being aware of it?
> 
> Not modifying type tags, but modifying data that has a type tag  
> without being aware of the fact that the data has a type tag, and  
> thus perhaps specific constraints on its contents. The most basic  
> example is calling dissoc on a map to remove a key that is required  
> by the semantics of the type implemented as a map. dissoc is agnostic  
> about type tags, so it won't complain.

Ahh, I see what you were getting at, and it is a more interesting point 
than I originally realized.  I guess to achieve this level of safety 
while still being map-compatible you would need to implement the 
Associative interface and maintain the constraints using getter/setters 
or something of the sort.

>> We've heard this line of reasoning before when moving from static to
>> dynamic languages.  If having the power to do what you want with the
>> language scares you, then maybe Java is a better choice.  All these
> 
> It doesn't scare me, otherwise I wouldn't be using Clojure. And I  
> wouldn't be using Python as my main language either. However, I think  
> it is important to be aware of the risks in order to watch out for them.
> 
>> Adding an implementation for a new type to a multimethod is equivalent
>> to adding an interface implementing method to a class you defined.  So
>> for example you could add to-string or to-xml or to-bytes or  
>> whatever to
>> your own objects to make them interoperate with some existing library.
>> Having libraries built on top of abstract interfaces like this is
>> exactly what makes them interesting.
> 
> I agree, of course. And yet, it is important to be aware of the  
> consequences. For example, don't ever try to memoize the dispatching  
> function of a multimethod - its result may well change after  
> importing another library module.
> 
> Konrad.

True.  Sorry if I came out swinging in the last message.  I've gotten 
sick of static typers spreading FUD about languages like Clojure not 
being usable for "real" or large pieces of software.  Your points are 
well taken.  Although I don't find them to be great risks, it is 
worthwhile to understand them.

-Jeff

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