For deeftype, has the syntax for field accessors changed too?

I can't get it to work:

user> (deftype someType [b f])
user.someType
user> (def y (new someType 2 3))
#'user/y
user> (:b y)
nil
user> (:f y)
nil

defrecord works as expected, though.


On Apr 17, 6:16 pm, Andrew Stein <steinl...@gmail.com> wrote:
> (deftype Bar [a b c d e])
> (def b (new Bar 1 2 3 4 5))
>
> There are a few other syntax changes too, defrecord replaces extending
> IPersistenMap, and you need to include 'this' in protocol fun
> implementations ...
>
> http://richhickey.github.com/clojure/clojure.core-api.html#clojure.co...http://richhickey.github.com/clojure/clojure.core-api.html#clojure.co...
>
> On Apr 17, 4:37 pm, Praki <praki.prak...@gmail.com> wrote:
>
>
>
>
>
> > I am seeing compilation errors in my code with deftype. I just updated
> > my project dependencies and probably pulled in the latest clojure
> > package. Anyway, the following code from wiki doesn't work anymore.
> > Pointers to any late breaking changes much appreciated!
>
> > TIA
>
> > (deftype Bar [a b c d e])
> > (def b (Bar 1 2 3 4 5))
>
> > Expecting var, but Bar is mapped to class package.Bar
> >   [Thrown class java.lang.Exception]
>
> > Restarts:
> >  0: [ABORT] Return to SLIME's top level.
>
> > Backtrace:
> >   0: clojure.lang.Compiler.lookupVar(Compiler.java:5677)
> >   1: clojure.lang.Compiler.isMacro(Compiler.java:5178)
> >   2: clojure.lang.Compiler.macroexpand1(Compiler.java:5233)
> >   3: clojure.lang.Compiler.analyzeSeq(Compiler.java:5305)
> >   4: clojure.lang.Compiler.analyze(Compiler.java:5140)
> >   5: clojure.lang.Compiler.access$100(Compiler.java:35)
> >   6: clojure.lang.Compiler$DefExpr$Parser.parse(Compiler.java:417)
> >   7: clojure.lang.Compiler.analyzeSeq(Compiler.java:5319)
> >   8: clojure.lang.Compiler.analyze(Compiler.java:5140)
> >   9: clojure.lang.Compiler.analyze(Compiler.java:5101)
> >  10: clojure.lang.Compiler.eval(Compiler.java:5377)
> >  11:
>
> > --
> > 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 
> > athttp://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 
> athttp://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