On Mar 29, 7:22 am, Konrad Hinsen <konrad.hin...@laposte.net> wrote:
> 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.

Sure, that's right. Maybe constructing such a value in the first place
is an error.

The fact remains that it's a Clojure value. If you want to write a
Clojure implementation of CLOS, then you need your dispatching code to
be able to handle all Clojure values. If it doesn't, you have not
written a Clojure implementation of CLOS. This "pathological object"
is a Clojure value. Clojure's "type" function doesn't presently return
a type for such values, so, in order to implement CLOS, you're going
to need to write another type-returning function.

Discussions of whether such values make sense is beside the point. As
long as Clojure allows you to make them, any implementation of CLOS
for Clojure needs to deal with them.

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