The constructor should be available, like in this contrived sample:

Clojure 1.5.1
user=> (deftype Foo [a] Object (toString [this] (Foo. 1)))
user.Foo

What error are you getting?

On Wednesday, July 31, 2013 5:51:36 PM UTC-7, JvJ wrote:
>
> I tried to define this record, but the Vec2. constructor doesn't exist yet.
> How can I use the constructor inside the record's method?
>
> (defrecord Vec2 [x y]
>
>   Vector
>   (mag [this]
>        (Math/sqrt
>         (+ (* x x) (* y y))))
>   
>   (v+ [this] this)
>    (v+ [this other]
>        (Vec2. (+ (:x this) (:x other)
>                  (:y this) (:y other))))
>   (v+ [this a b & c]
>       (reduce v+
>               this
>               (conj c b a))))
>

-- 
-- 
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
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to