You can use record's positional constructor: user> (defrecord R [a]) user.R user> ((find-var (symbol "user/->R")) 5) #user.R{:a 5}
JW On Wednesday, August 6, 2014 12:51:11 PM UTC+2, Ambrose Bonnaire-Sergeant wrote: > > Hi Colin, > > If you must call the Java constructor, you need reflection. > > user=> (defrecord B [c]) > user.B > user=> (def s "user.B") > #'user/s > user=> (.newInstance (first (.getDeclaredConstructors (Class/forName s))) > (object-array [1])) > #user.B{:c 1} > > Thanks, > Ambrose > > > On Wed, Aug 6, 2014 at 6:37 PM, Colin Yates <colin...@gmail.com > <javascript:>> wrote: > >> Hi, >> >> tldr; if I have a (defrecord MyRecord) in ns a.b.c and I have a string >> "a.b.c.MyRecord" how I can invoke (a.b.c.MyRecord.) (or (new >> a.b.c.MyRecord)? >> >> I thought this was going to be as simple as (defn cfn "a.b.c.MyRecord") >> ((symbol cfn).) but that throws an ArityException: wrong number of args (0) >> passed to Symbol. I >> >> I have a protocol with a number of implementations. Each installation >> will have a single implementation and will chose one based on an >> environment variable. At runtime I need to look at that environment >> variable which defines the fully qualified implementation of a protocol. I >> then need to instantiate that record. >> >> Architecturally equivalent to a simple plugin system. I could alias them >> all but that requires knowing about all the implementations which is a >> no-go. >> >> This is where I feel the pain of not having OSGi :). >> >> Thanks all! >> >> -- >> You received this message because you are subscribed to the Google >> Groups "Clojure" group. >> To post to this group, send email to clo...@googlegroups.com >> <javascript:> >> Note that posts from new members are moderated - please be patient with >> your first post. >> To unsubscribe from this group, send email to >> clojure+u...@googlegroups.com <javascript:> >> 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+u...@googlegroups.com <javascript:>. >> For more options, visit https://groups.google.com/d/optout. >> > > -- 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/d/optout.