Re: Create an instance of a record using a string to define the record's symbol

2014-08-06 Thread Colin Yates
Thanks both. On Wednesday, 6 August 2014 12:02:59 UTC+1, Ambrose Bonnaire-Sergeant wrote: > > The `new` reader macro must resolve its first argument at compile time. > > That's why (new (symbol s)) doesn't work. > > Thanks, > Ambrose > > > On Wed, Aug 6, 2014 at 6:55 PM, Colin Yates > wrote: > >>

Re: Create an instance of a record using a string to define the record's symbol

2014-08-06 Thread Ambrose Bonnaire-Sergeant
The `new` reader macro must resolve its first argument at compile time. That's why (new (symbol s)) doesn't work. Thanks, Ambrose On Wed, Aug 6, 2014 at 6:55 PM, Colin Yates wrote: > Ah OK, I didn't realise I needed to get into Java interop. > > For education - can you (or anyone) explain me

Re: Create an instance of a record using a string to define the record's symbol

2014-08-06 Thread Jozef Wagner
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. >

Re: Create an instance of a record using a string to define the record's symbol

2014-08-06 Thread Colin Yates
Ah OK, I didn't realise I needed to get into Java interop. For education - can you (or anyone) explain me as to why what I was trying didn't work? Thanks Ambrose. On 6 August 2014 11:50, Ambrose Bonnaire-Sergeant < abonnaireserge...@gmail.com> wrote: > Hi Colin, > > If you must call the Java c

Re: Create an instance of a record using a string to define the record's symbol

2014-08-06 Thread Ambrose Bonnaire-Sergeant
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, Col