On Dec 6, 12:29 pm, Bob Hutchison <hutch-li...@recursive.ca> wrote: > Hi, > > I'm new to Clojure, not new to lisp (CL and scheme), and having a > thoroughly good time. I've been having a go at the new deftype stuff > and using a clone of the new branch from the git repository (up-to- > date as of this message being posted). So far everything I've tried > has worked very nicely, except for one thing. > > I've put three files up as a gist:http://gist.github.com/250364that > illustrate (I hope) my question. > > So. I've defined a type 'Foo -- inevitably foo, sorry -- and I want to > define a very simple multimethod that dispatches on the class of its > single argument. I understand that defmethod needs a fully ns > qualified name to dispatch properly. I was hoping there was a shorter > way of doing this than play.foo.Foo, maybe using some sort of alias- > based technique like those in Stuary Halloway's book (p233 and > thereabout). > > I've got six variations in there, and I know full well that most of > these should not work, but I put them in anyway. > > I believe that I'm AOT compiling everything (I'm compiling the ./src/ > play/foo.clj file and the class files are on disk, so...) > > It turns out that dispatching on play.foo.Foo is the only way that > works. I was hoping ::f/Foo or f/Foo would work too (maybe my alias is > wrong??). Especially since, with aliasing in the user namespace, I can > create a play.foo.Foo using f/Foo > > Obviously, I have a workaround, but that's going to get ugly fast with > a real namespace name, not to mention making re-naming the namespace > harder than it should be. > > If someone could help me out I'd appreciate it. > > Thanks, > Bob > > ---- > Bob Hutchison > Recursive Design Inc.http://www.recursive.ca/ > weblog:http://www.recursive.ca/hutch
While there may be a way to work around it, if you're just dispatching on the type of the first arg, you might want to use defprotocol instead of defmulti. -- 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 Note that posts from new members are moderated - please be patient with your first post. 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