This is what I'm looking for. Thanks. I have not seen this kind of
expression before: ->foo. Is is created by defrecord or is it
implemented at reader level?

I realize now that I can also keep a generating function in the
variable stuff:

(let [stuff #(car. %1 %2)]
  (stuff 1982 "Mercedes")
  (stuff 2011 "Seat"))

But keeping the actual "constructor" is of course better.

RR


On Oct 6, 8:56 pm, Meikel Brandmeyer <m...@kotka.de> wrote:
> Hi,
>
> use the factory function.
>
> Clojure 1.3.0
> user=> (defrecord car [year manufacturer])
> user.car
> user=> (defn create [stuff] (stuff 1982 "Mercedes Benz"))
> #'user/create
> user=> (create ->car)
> #user.car{:year 1982, :manufacturer "Mercedes Benz"}
>
> You can't pass car. around at runtime because it is a class. And 
> instantiating a class is hard-wired in the byte code. Hence the actual class 
> must be known at compile time. ->car however is a normal clojure function. So 
> you can pass it around as you like.
>
> Sincerely
> Meikel

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