thanks Alex for your response . I tried it ... It compiled fine .. but the
double dispatch does not seem to work correctly ..

 It some how reverses the arguments and then dispatches to the correct
function for the reversed arguments and the function works properly ..
i.e.
 when I do (- (Complex. 1 3) 3)  .. I would expect (Complex. -2 3) but I get
(Complex. 2 -3)
which is what I would expect to get when I do (- 3 (Complex. 1 3)) .

I am trying to make it work right .. but I thought some of you may better
able to fix it.

Thanks,
Sunil


 I am trying to debug it .. but would like some

 I am still trying to understand the code and figure it out.. But I just
thought I

On Mon, Dec 27, 2010 at 6:03 AM, Alex Osborne <a...@meshy.org> wrote:

> Sunil S Nandihalli <sunil.nandiha...@gmail.com> writes:
>
> > http://paste.lisp.org/display/93387
> >
> > It uses protocols and deftype I noticed that it was an old post .. I
> > could not get it to compile to try it out.. I was complaining about
> > likes of trying to convert a name-space-qualified to a type name
> > .. w.r.t ::Complex . I tried a  couple of things to get it working
> > with out success..
>
> > Any suggestions to improve my code or to get stuart's code compiled so
> > that I can try it would be very help full.
>
> Here's how to get Stuart's working.
>
> 1. Replace "::Complex" with "Complex" everywhere.
>
> 2. Change (deftype Complex [r i]) to (defrecord Complex [r i]).
>
> 3. Put a . after the Complex constructors so they look like this:
>
>    (extend-double add Complex Complex
>                   (fn [c1 c2] (Complex. (+ (:r c1) (:r c2))
>                                         (+ (:i c1) (:i c2)))))
>
> You should end up with something vaguely like this:
>
>    https://gist.github.com/755758
>
> --
> 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<clojure%2bunsubscr...@googlegroups.com>
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en

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

Reply via email to