There are some simple things you have to understand when you want to
know why you cant have:
(defrecord Person [foo bar])
((Person. "1" "2") :foo)

In Clojure something after a "(" gets called as a function. A function
is something that can be "applied" (not the "apply" function.
"applied" is now implmented on the JVM with the meaning that the
"object" supports the IFn Interface (in CoffeeScript probebly the IFn
prototype).

So this tells us that a Person record does not have a IFn
implmentation and can because of that not work. Solving the problem is
easy. Just implment it by expaning the interface zu set type.

The question we could ask know is why it it not included in the
standart record? Records have some things that probebly will be
addressed in future versions of clojure (standart constructur for
example) maybe making them callable will be something like that. I
mean if you want an object without interfaces you always have deftype.
Stuard answerd this kinda answerd this allready:

> Aren't defrecords supposed to be drop-in specializations of  maps?
Where maps are used as records, but not where maps are used as
collections.

I would be intressted to know why it was doen this way. Personlly I
don't mind either way.

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