On Thu, Feb 3, 2011 at 10:11 PM, Aaron Cohen <aa...@assonance.org> wrote:
> On Thu, Feb 3, 2011 at 10:04 PM, Quzanti <quza...@googlemail.com> wrote:
>>
>>
>>> I see no reason for the ctor to be defined as a string as you've done with
>>> "Person.".
>>
>> The reason is that I am reading in XML and mapping a tag name to the
>> record class.
>
> It's possible to do this using reflection, but I don't recommend it.
>
> I think you're probably better off making a map of your tag names to
> factory functions, then just applying the factory function to your
> parameters.
>
> (def record-factories {"Person #(Person. %1 %2)})

Perils of copy-paste to an email window... that's missing a quotation mark.

> user=>(apply (record-factories "Person") ["Aaron" 31])
> #:user.Person{:name "Aaron", :age 31}
>

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