On 29.03.2009, at 07:25, mikel wrote:

>> Enjoying the thread. Out of curiosity for which Clojure values is  
>> the return
>> value of the type function undefined?
>
> Try this:
>
> (type (proxy [clojure.lang.IMeta clojure.lang.IRef][]))
>
> java.lang.UnsupportedOperationException: meta (NO_SOURCE_FILE:0)
>   [Thrown class clojure.lang.Compiler$CompilerException]
>
>
> No doubt someone is going to point out that the proxy object I created
> there is useless; that's true, but beside the point.

Not entirely. Your example object is not only useless, it is as close  
as possible to an object created intentionally to cause trouble. You  
create an object that derives from IMeta, thus claiming that it  
handles metadata, but then don't provide an implementation that would  
actually make metadata work.

BTW, the function type could easily be fixed to handle your problem.  
At the moment it does

        (or (:type (meta x)) (class x))

Adding an exception handler that returns (class x) whenever (meta x)  
fails would take care of your pathological object. I can't say if  
this would add much runtime overhead, not being much of a JVM expert.

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