Re: new, macros and Can't eval locals

2013-02-16 Thread Jacob Goodson
You need to know something... it's a dialect of LISP, the only limitation 
is you.

On Thursday, February 14, 2013 5:08:57 PM UTC-5, AtKaaZ wrote:

 Thank you! I didn't know you could do .newInstance

 oh that's a nice trick with eval and list 'new

 So it's not impossible after all, thanks Aaron!
 Here's what I got from what you said:
 = *(defmacro mew [cls  restt]
`(eval (list 'new ~cls ~@restt))
  )*
 #'runtime.q/mew
 = *(let [a java.lang.RuntimeException]
(mew a)
  )*
 #RuntimeException java.lang.RuntimeException

 it makes sense now, using eval at runtime not at compile time as I was 
 trying

 and also the newInstance variant:
 = *(defmacro mew [cls  restt]
`(.newInstance ~cls ~@restt)
  )*
 #'runtime.q/mew
 = *(let [a java.lang.RuntimeException]
(mew a)
  )*
 #RuntimeException java.lang.RuntimeException


 Really, thank you Aaron, 


 On Thu, Feb 14, 2013 at 11:02 PM, Aaron Cohen 
 aa...@assonance.orgjavascript:
  wrote:

 Yes, since this is runtime you should use reflection.

 (let [a java.lang.RuntimeException]
(.newInstance a))

 Alternatively, you can use eval:

 (let [a java.lang.RuntimeException]
   (eval (list 'new a)))


 On Thu, Feb 14, 2013 at 4:53 PM, AtKaaZ atk...@gmail.com 
 javascript:wrote:

 I figure since new is expecting a class at compiletime, we can never 
 pass it a class that we evaluate at runtime(those locals), ergo = 
 impossible to macro around new like that

 like this = impossible:
 *(let [a java.lang.RuntimeException]
  (macro-that-eventually-calls-new a))*

 maybe someone could suggest another way? clojure.reflect ?



 On Thu, Feb 14, 2013 at 10:40 PM, AtKaaZ atk...@gmail.com javascript:
  wrote:

 thanks for the reply,

 = *(defmacro mew [cls  args]
  `(new ~cls ~@args))*
 #'runtime.q/mew
 =* (let [a java.lang.RuntimeException]
  (mew a)
  )*

 CompilerException java.lang.IllegalArgumentException: Unable to resolve 
 classname: a, compiling:(NO_SOURCE_PATH:2:3) 

 that would be the equivalent macro of what *new* is doing
 it's like
 *(new a)*
 CompilerException java.lang.IllegalArgumentException: Unable to resolve 
 classname: a, compiling:(NO_SOURCE_PATH:2:3) 


 This is the goal:

 The goal is to can write this form:
 =  *(let [a java.lang.RuntimeException]
  (new a))*

 but I think it's impossible, at least by using new it is


 On Thu, Feb 14, 2013 at 10:34 PM, Andy Fingerhut 
 andy.fi...@gmail.comjavascript:
  wrote:


 On Feb 14, 2013, at 1:27 PM, AtKaaZ wrote:

 The goal is to can write this form:
 = *(let [a java.lang.RuntimeException]
  (new a)
  )*
 CompilerException java.lang.IllegalArgumentException: Unable to 
 resolve classname: a, compiling:(NO_SOURCE_PATH:2:3) 

 attempt with macro:
 =* (defmacro mew [cls  restt]
  `(new ~(eval cls) ~@restt)
  )*
 #'runtime.q/mew


 This is probably your closest attempt.  Try this variation on the 
 above:

 (defmacro mew [cls  args]
   `(new ~cls ~@args))

 user= (macroexpand-1 '(mew java.lang.RuntimeException))
 (new java.lang.RuntimeException)

 Andy

  -- 
 -- 
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clo...@googlegroups.comjavascript:
 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/groups/opt_out.
  
  




 -- 
 Please correct me if I'm wrong or incomplete,
 even if you think I'll subconsciously hate it.

  


 -- 
 Please correct me if I'm wrong or incomplete,
 even if you think I'll subconsciously hate it.

  -- 
 -- 
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clo...@googlegroups.comjavascript:
 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/groups/opt_out.
  
  


  -- 
 -- 
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clo...@googlegroups.comjavascript:
 Note that posts from new members 

Re: new, macros and Can't eval locals

2013-02-16 Thread AtKaaZ
On Sun, Feb 17, 2013 at 6:12 AM, Jacob Goodson
submissionfight...@gmx.comwrote:

 You need to know something... it's a dialect of LISP, *the only*limitation is 
 you.

though it is certainly exerting its limitations on me





 On Thursday, February 14, 2013 5:08:57 PM UTC-5, AtKaaZ wrote:

 Thank you! I didn't know you could do .newInstance

 oh that's a nice trick with eval and list 'new

 So it's not impossible after all, thanks Aaron!
 Here's what I got from what you said:
 = *(defmacro mew [cls  restt]
`(eval (list 'new ~cls ~@restt))
  )*
 #'runtime.q/mew
 = *(let [a java.lang.RuntimeException]
(mew a)
  )*
 #RuntimeException java.lang.RuntimeException

 it makes sense now, using eval at runtime not at compile time as I was
 trying

 and also the newInstance variant:
 = *(defmacro mew [cls  restt]
`(.newInstance ~cls ~@restt)
  )*
 #'runtime.q/mew
 = *(let [a java.lang.RuntimeException]
(mew a)
  )*
 #RuntimeException java.lang.RuntimeException


 Really, thank you Aaron,


 On Thu, Feb 14, 2013 at 11:02 PM, Aaron Cohen aa...@assonance.orgwrote:

 Yes, since this is runtime you should use reflection.

 (let [a java.lang.RuntimeException]
(.newInstance a))

 Alternatively, you can use eval:

 (let [a java.lang.RuntimeException]
   (eval (list 'new a)))


 On Thu, Feb 14, 2013 at 4:53 PM, AtKaaZ atk...@gmail.com wrote:

 I figure since new is expecting a class at compiletime, we can never
 pass it a class that we evaluate at runtime(those locals), ergo =
 impossible to macro around new like that

 like this = impossible:
 *(let [a java.lang.RuntimeException]
  (macro-that-eventually-calls-new a))*

 maybe someone could suggest another way? clojure.reflect ?



 On Thu, Feb 14, 2013 at 10:40 PM, AtKaaZ atk...@gmail.com wrote:

 thanks for the reply,

 = *(defmacro mew [cls  args]
  `(new ~cls ~@args))*
 #'runtime.q/mew
 =* (let [a java.lang.RuntimeException]
  (mew a)
  )*

 CompilerException java.lang.**IllegalArgumentException: Unable to
 resolve classname: a, compiling:(NO_SOURCE_PATH:2:3)

 that would be the equivalent macro of what *new* is doing
 it's like
 *(new a)*
 CompilerException java.lang.**IllegalArgumentException: Unable to
 resolve classname: a, compiling:(NO_SOURCE_PATH:2:3)


 This is the goal:

 The goal is to can write this form:
 =  *(let [a java.lang.RuntimeException]
  (new a))*

 but I think it's impossible, at least by using new it is


 On Thu, Feb 14, 2013 at 10:34 PM, Andy Fingerhut andy.fi...@gmail.com
  wrote:


 On Feb 14, 2013, at 1:27 PM, AtKaaZ wrote:

 The goal is to can write this form:
 = *(let [a java.lang.RuntimeException]
  (new a)
  )*
 CompilerException java.lang.**IllegalArgumentException: Unable to
 resolve classname: a, compiling:(NO_SOURCE_PATH:2:3)

 attempt with macro:
 =* (defmacro mew [cls  restt]
  `(new ~(eval cls) ~@restt)
  )*
 #'runtime.q/mew


 This is probably your closest attempt.  Try this variation on the
 above:

 (defmacro mew [cls  args]
   `(new ~cls ~@args))

 user= (macroexpand-1 '(mew java.lang.RuntimeException))
 (new java.lang.RuntimeException)

 Andy

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

 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

 For more options, visit this group at
 http://groups.google.com/**group/clojure?hl=enhttp://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.

 For more options, visit 
 https://groups.google.com/**groups/opt_outhttps://groups.google.com/groups/opt_out
 .






 --
 Please correct me if I'm wrong or incomplete,
 even if you think I'll subconsciously hate it.




 --
 Please correct me if I'm wrong or incomplete,
 even if you think I'll subconsciously hate it.

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

 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

 For more options, visit this group at
 http://groups.google.com/**group/clojure?hl=enhttp://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.

 For more options, visit 
 https://groups.google.com/**groups/opt_outhttps://groups.google.com/groups/opt_out
 .




  --
 --
 You received 

new, macros and Can't eval locals

2013-02-14 Thread AtKaaZ
The goal is to can write this form:
= *(let [a java.lang.RuntimeException]
 (new a)
 )*
CompilerException java.lang.IllegalArgumentException: Unable to resolve
classname: a, compiling:(NO_SOURCE_PATH:2:3)

attempt with macro:
=* (defmacro mew [cls  restt]
 `(new ~(eval cls) ~@restt)
 )*
#'runtime.q/mew
= *(let [a java.lang.RuntimeException]
 (mew a)
 )*
CompilerException java.lang.UnsupportedOperationException: Can't eval
locals, compiling:(NO_SOURCE_PATH:2:3)

attempt with function:
= *(defn mew [cls  restt]
 (new cls)
 )*
CompilerException java.lang.IllegalArgumentException: Unable to resolve
classname: cls, compiling:(NO_SOURCE_PATH:2:3)

attempt with a macro inside the function:
= *(defn mew [cls  restt]
 (mew cls)
 )*
CompilerException java.lang.UnsupportedOperationException: Can't eval
locals, compiling:(NO_SOURCE_PATH:2:3)

Ok, i give up, how? impossible ?

-- 
Please correct me if I'm wrong or incomplete,
even if you think I'll subconsciously hate it.

-- 
-- 
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/groups/opt_out.




Re: new, macros and Can't eval locals

2013-02-14 Thread Andy Fingerhut

On Feb 14, 2013, at 1:27 PM, AtKaaZ wrote:

 The goal is to can write this form:
 = (let [a java.lang.RuntimeException]
  (new a)
  )
 CompilerException java.lang.IllegalArgumentException: Unable to resolve 
 classname: a, compiling:(NO_SOURCE_PATH:2:3) 
 
 attempt with macro:
 = (defmacro mew [cls  restt]
  `(new ~(eval cls) ~@restt)
  )
 #'runtime.q/mew

This is probably your closest attempt.  Try this variation on the above:

(defmacro mew [cls  args]
  `(new ~cls ~@args))

user= (macroexpand-1 '(mew java.lang.RuntimeException))
(new java.lang.RuntimeException)

Andy

-- 
-- 
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/groups/opt_out.




Re: new, macros and Can't eval locals

2013-02-14 Thread AtKaaZ
thanks for the reply,

= *(defmacro mew [cls  args]
 `(new ~cls ~@args))*
#'runtime.q/mew
=* (let [a java.lang.RuntimeException]
 (mew a)
 )*
CompilerException java.lang.IllegalArgumentException: Unable to resolve
classname: a, compiling:(NO_SOURCE_PATH:2:3)

that would be the equivalent macro of what *new* is doing
it's like
*(new a)*
CompilerException java.lang.IllegalArgumentException: Unable to resolve
classname: a, compiling:(NO_SOURCE_PATH:2:3)


This is the goal:
The goal is to can write this form:
=  *(let [a java.lang.RuntimeException]
 (new a))*

but I think it's impossible, at least by using new it is


On Thu, Feb 14, 2013 at 10:34 PM, Andy Fingerhut
andy.finger...@gmail.comwrote:


 On Feb 14, 2013, at 1:27 PM, AtKaaZ wrote:

 The goal is to can write this form:
 = *(let [a java.lang.RuntimeException]
  (new a)
  )*
 CompilerException java.lang.IllegalArgumentException: Unable to resolve
 classname: a, compiling:(NO_SOURCE_PATH:2:3)

 attempt with macro:
 =* (defmacro mew [cls  restt]
  `(new ~(eval cls) ~@restt)
  )*
 #'runtime.q/mew


 This is probably your closest attempt.  Try this variation on the above:

 (defmacro mew [cls  args]
   `(new ~cls ~@args))

 user= (macroexpand-1 '(mew java.lang.RuntimeException))
 (new java.lang.RuntimeException)

 Andy

  --
 --
 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/groups/opt_out.






-- 
Please correct me if I'm wrong or incomplete,
even if you think I'll subconsciously hate it.

-- 
-- 
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/groups/opt_out.




Re: new, macros and Can't eval locals

2013-02-14 Thread AtKaaZ
I figure since new is expecting a class at compiletime, we can never pass
it a class that we evaluate at runtime(those locals), ergo = impossible to
macro around new like that

like this = impossible:
*(let [a java.lang.RuntimeException]
 (macro-that-eventually-calls-new a))*

maybe someone could suggest another way? clojure.reflect ?



On Thu, Feb 14, 2013 at 10:40 PM, AtKaaZ atk...@gmail.com wrote:

 thanks for the reply,

 = *(defmacro mew [cls  args]
  `(new ~cls ~@args))*
 #'runtime.q/mew
 =* (let [a java.lang.RuntimeException]
  (mew a)
  )*

 CompilerException java.lang.IllegalArgumentException: Unable to resolve
 classname: a, compiling:(NO_SOURCE_PATH:2:3)

 that would be the equivalent macro of what *new* is doing
 it's like
 *(new a)*
 CompilerException java.lang.IllegalArgumentException: Unable to resolve
 classname: a, compiling:(NO_SOURCE_PATH:2:3)


 This is the goal:

 The goal is to can write this form:
 =  *(let [a java.lang.RuntimeException]
  (new a))*

 but I think it's impossible, at least by using new it is


 On Thu, Feb 14, 2013 at 10:34 PM, Andy Fingerhut andy.finger...@gmail.com
  wrote:


 On Feb 14, 2013, at 1:27 PM, AtKaaZ wrote:

 The goal is to can write this form:
 = *(let [a java.lang.RuntimeException]
  (new a)
  )*
 CompilerException java.lang.IllegalArgumentException: Unable to resolve
 classname: a, compiling:(NO_SOURCE_PATH:2:3)

 attempt with macro:
 =* (defmacro mew [cls  restt]
  `(new ~(eval cls) ~@restt)
  )*
 #'runtime.q/mew


 This is probably your closest attempt.  Try this variation on the above:

 (defmacro mew [cls  args]
   `(new ~cls ~@args))

 user= (macroexpand-1 '(mew java.lang.RuntimeException))
 (new java.lang.RuntimeException)

 Andy

  --
 --
 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/groups/opt_out.






 --
 Please correct me if I'm wrong or incomplete,
 even if you think I'll subconsciously hate it.




-- 
Please correct me if I'm wrong or incomplete,
even if you think I'll subconsciously hate it.

-- 
-- 
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/groups/opt_out.




Re: new, macros and Can't eval locals

2013-02-14 Thread AtKaaZ
ok looks like it's not impossible:
= *(defmacro mew [cls  restt]
 (let [c a]
   `(eval (new ~a ~@restt))
   )
 )*
#'runtime.q/mew
= *(let [a java.lang.RuntimeException]
 (mew a)
 )*
#RuntimeException java.lang.RuntimeException



On Thu, Feb 14, 2013 at 10:53 PM, AtKaaZ atk...@gmail.com wrote:

 I figure since new is expecting a class at compiletime, we can never pass
 it a class that we evaluate at runtime(those locals), ergo = impossible to
 macro around new like that

 like this = impossible:
 *(let [a java.lang.RuntimeException]
  (macro-that-eventually-calls-new a))*

 maybe someone could suggest another way? clojure.reflect ?



 On Thu, Feb 14, 2013 at 10:40 PM, AtKaaZ atk...@gmail.com wrote:

 thanks for the reply,

 = *(defmacro mew [cls  args]
  `(new ~cls ~@args))*
 #'runtime.q/mew
 =* (let [a java.lang.RuntimeException]
  (mew a)
  )*

 CompilerException java.lang.IllegalArgumentException: Unable to resolve
 classname: a, compiling:(NO_SOURCE_PATH:2:3)

 that would be the equivalent macro of what *new* is doing
 it's like
 *(new a)*
 CompilerException java.lang.IllegalArgumentException: Unable to resolve
 classname: a, compiling:(NO_SOURCE_PATH:2:3)


 This is the goal:

 The goal is to can write this form:
 =  *(let [a java.lang.RuntimeException]
  (new a))*

 but I think it's impossible, at least by using new it is


 On Thu, Feb 14, 2013 at 10:34 PM, Andy Fingerhut 
 andy.finger...@gmail.com wrote:


 On Feb 14, 2013, at 1:27 PM, AtKaaZ wrote:

 The goal is to can write this form:
 = *(let [a java.lang.RuntimeException]
  (new a)
  )*
 CompilerException java.lang.IllegalArgumentException: Unable to resolve
 classname: a, compiling:(NO_SOURCE_PATH:2:3)

 attempt with macro:
 =* (defmacro mew [cls  restt]
  `(new ~(eval cls) ~@restt)
  )*
 #'runtime.q/mew


 This is probably your closest attempt.  Try this variation on the above:

 (defmacro mew [cls  args]
   `(new ~cls ~@args))

 user= (macroexpand-1 '(mew java.lang.RuntimeException))
 (new java.lang.RuntimeException)

 Andy

  --
 --
 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/groups/opt_out.






 --
 Please correct me if I'm wrong or incomplete,
 even if you think I'll subconsciously hate it.




 --
 Please correct me if I'm wrong or incomplete,
 even if you think I'll subconsciously hate it.




-- 
Please correct me if I'm wrong or incomplete,
even if you think I'll subconsciously hate it.

-- 
-- 
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/groups/opt_out.




Re: new, macros and Can't eval locals

2013-02-14 Thread AtKaaZ
and I forgot to mention that I already had another a defined
= a
java.lang.RuntimeException

hence why it worked


On Thu, Feb 14, 2013 at 11:01 PM, AtKaaZ atk...@gmail.com wrote:

 ah I tricked myself... I used ~a  inside the macro instead of ~c or
 ~cls
 so back to still impossible

 = (defmacro mew [cls  restt]
  (let [c cls]
`(eval (new ~c ~@restt))

)
  )
 #'runtime.q/mew
 = (let [a java.lang.RuntimeException]
  (mew a)
  )
 CompilerException java.lang.IllegalArgumentException: Unable to resolve
 classname: a, compiling:(NO_SOURCE_PATH:2:3)
 = (defmacro mew [cls  restt]
  `(eval (new ~cls ~@restt))

  )
 #'runtime.q/mew
 = (let [a java.lang.RuntimeException]
  (mew a)
  )
 CompilerException java.lang.IllegalArgumentException: Unable to resolve
 classname: a, compiling:(NO_SOURCE_PATH:2:3)


 On Thu, Feb 14, 2013 at 10:58 PM, AtKaaZ atk...@gmail.com wrote:

 ok looks like it's not impossible:
 = *(defmacro mew [cls  restt]
  (let [c a]
`(eval (new ~a ~@restt))
)
  )*

 #'runtime.q/mew
 = *(let [a java.lang.RuntimeException]
  (mew a)
  )*
 #RuntimeException java.lang.RuntimeException



 On Thu, Feb 14, 2013 at 10:53 PM, AtKaaZ atk...@gmail.com wrote:

 I figure since new is expecting a class at compiletime, we can never
 pass it a class that we evaluate at runtime(those locals), ergo =
 impossible to macro around new like that

 like this = impossible:
 *(let [a java.lang.RuntimeException]
  (macro-that-eventually-calls-new a))*

 maybe someone could suggest another way? clojure.reflect ?



 On Thu, Feb 14, 2013 at 10:40 PM, AtKaaZ atk...@gmail.com wrote:

 thanks for the reply,

 = *(defmacro mew [cls  args]
  `(new ~cls ~@args))*
 #'runtime.q/mew
 =* (let [a java.lang.RuntimeException]
  (mew a)
  )*

 CompilerException java.lang.IllegalArgumentException: Unable to resolve
 classname: a, compiling:(NO_SOURCE_PATH:2:3)

 that would be the equivalent macro of what *new* is doing
 it's like
 *(new a)*
 CompilerException java.lang.IllegalArgumentException: Unable to resolve
 classname: a, compiling:(NO_SOURCE_PATH:2:3)


 This is the goal:

 The goal is to can write this form:
 =  *(let [a java.lang.RuntimeException]
  (new a))*

 but I think it's impossible, at least by using new it is


 On Thu, Feb 14, 2013 at 10:34 PM, Andy Fingerhut 
 andy.finger...@gmail.com wrote:


 On Feb 14, 2013, at 1:27 PM, AtKaaZ wrote:

 The goal is to can write this form:
 = *(let [a java.lang.RuntimeException]
  (new a)
  )*
 CompilerException java.lang.IllegalArgumentException: Unable to
 resolve classname: a, compiling:(NO_SOURCE_PATH:2:3)

 attempt with macro:
 =* (defmacro mew [cls  restt]
  `(new ~(eval cls) ~@restt)
  )*
 #'runtime.q/mew


 This is probably your closest attempt.  Try this variation on the
 above:

 (defmacro mew [cls  args]
   `(new ~cls ~@args))

 user= (macroexpand-1 '(mew java.lang.RuntimeException))
 (new java.lang.RuntimeException)

 Andy

  --
 --
 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/groups/opt_out.






 --
 Please correct me if I'm wrong or incomplete,
 even if you think I'll subconsciously hate it.




 --
 Please correct me if I'm wrong or incomplete,
 even if you think I'll subconsciously hate it.




 --
 Please correct me if I'm wrong or incomplete,
 even if you think I'll subconsciously hate it.




 --
 Please correct me if I'm wrong or incomplete,
 even if you think I'll subconsciously hate it.




-- 
Please correct me if I'm wrong or incomplete,
even if you think I'll subconsciously hate it.

-- 
-- 
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/groups/opt_out.




Re: new, macros and Can't eval locals

2013-02-14 Thread Aaron Cohen
Yes, since this is runtime you should use reflection.

(let [a java.lang.RuntimeException]
   (.newInstance a))

Alternatively, you can use eval:

(let [a java.lang.RuntimeException]
  (eval (list 'new a)))


On Thu, Feb 14, 2013 at 4:53 PM, AtKaaZ atk...@gmail.com wrote:

 I figure since new is expecting a class at compiletime, we can never pass
 it a class that we evaluate at runtime(those locals), ergo = impossible to
 macro around new like that

 like this = impossible:
 *(let [a java.lang.RuntimeException]
  (macro-that-eventually-calls-new a))*

 maybe someone could suggest another way? clojure.reflect ?



 On Thu, Feb 14, 2013 at 10:40 PM, AtKaaZ atk...@gmail.com wrote:

 thanks for the reply,

 = *(defmacro mew [cls  args]
  `(new ~cls ~@args))*
 #'runtime.q/mew
 =* (let [a java.lang.RuntimeException]
  (mew a)
  )*

 CompilerException java.lang.IllegalArgumentException: Unable to resolve
 classname: a, compiling:(NO_SOURCE_PATH:2:3)

 that would be the equivalent macro of what *new* is doing
 it's like
 *(new a)*
 CompilerException java.lang.IllegalArgumentException: Unable to resolve
 classname: a, compiling:(NO_SOURCE_PATH:2:3)


 This is the goal:

 The goal is to can write this form:
 =  *(let [a java.lang.RuntimeException]
  (new a))*

 but I think it's impossible, at least by using new it is


 On Thu, Feb 14, 2013 at 10:34 PM, Andy Fingerhut 
 andy.finger...@gmail.com wrote:


 On Feb 14, 2013, at 1:27 PM, AtKaaZ wrote:

 The goal is to can write this form:
 = *(let [a java.lang.RuntimeException]
  (new a)
  )*
 CompilerException java.lang.IllegalArgumentException: Unable to resolve
 classname: a, compiling:(NO_SOURCE_PATH:2:3)

 attempt with macro:
 =* (defmacro mew [cls  restt]
  `(new ~(eval cls) ~@restt)
  )*
 #'runtime.q/mew


 This is probably your closest attempt.  Try this variation on the above:

 (defmacro mew [cls  args]
   `(new ~cls ~@args))

 user= (macroexpand-1 '(mew java.lang.RuntimeException))
 (new java.lang.RuntimeException)

 Andy

  --
 --
 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/groups/opt_out.






 --
 Please correct me if I'm wrong or incomplete,
 even if you think I'll subconsciously hate it.




 --
 Please correct me if I'm wrong or incomplete,
 even if you think I'll subconsciously hate it.

  --
 --
 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/groups/opt_out.




-- 
-- 
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/groups/opt_out.