Re: Namespace qualification of symbols

2013-06-20 Thread MichaƂ Marczyk
On 20 June 2013 14:35, Phillip Lord wrote: > Oh yeah, how sneaky. In one case, you get a class, in the other, you get > a symbol. Backtick is doing quite a bit more than letting you unquote > and splice. You get a symbol in both cases, though with a different name: (import java.awt.image.Buffere

Re: Namespace qualification of symbols

2013-06-20 Thread Ambrose Bonnaire-Sergeant
On Thu, Jun 20, 2013 at 8:50 PM, Phillip Lord wrote: > Thanks for the explanation. I was confused. Cheers, glad it helped. Ambrose -- -- 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 No

Re: Namespace qualification of symbols

2013-06-20 Thread Phillip Lord
"Jim - FooBar();" writes: > On 20/06/13 08:49, Phillip Lord wrote: >> Well, that doesn't answer the question. The backtick is useful in >> writing macros (although the situation this caused me grief, actually, I >> wasn't). So is quote. But then I do not understand why the behaviour is >> differen

Re: Namespace qualification of symbols

2013-06-20 Thread Phillip Lord
Oh yeah, how sneaky. In one case, you get a class, in the other, you get a symbol. Backtick is doing quite a bit more than letting you unquote and splice. Colin Fleming writes: > Thank you for this, you just fixed a bug for me :-) > > I was trying to do some tricky type hinting with definline us

Re: Namespace qualification of symbols

2013-06-20 Thread Phillip Lord
Ambrose Bonnaire-Sergeant writes: > It's a good question. > > Syntax quote is designed for generating code/syntax that is deterministic > and avoids accidental local name capture. > > 1. Automatic namespace qualification helps avoid accidental local name > capture in macros. > > user=> `(let [a# 1

Re: Namespace qualification of symbols

2013-06-20 Thread Jim - FooBar();
On 20/06/13 08:49, Phillip Lord wrote: Well, that doesn't answer the question. The backtick is useful in writing macros (although the situation this caused me grief, actually, I wasn't). So is quote. But then I do not understand why the behaviour is different between the two. I thought the ques

Re: Namespace qualification of symbols

2013-06-20 Thread Ambrose Bonnaire-Sergeant
Hi Phil, It's a good question. Syntax quote is designed for generating code/syntax that is deterministic and avoids accidental local name capture. 1. Automatic namespace qualification helps avoid accidental local name capture in macros. user=> `(let [a# 1 b# a] a#) (cloj

Re: Namespace qualification of symbols

2013-06-20 Thread Phillip Lord
Jim writes: > On 19/06/13 09:46, Phillip Lord wrote: >> With the ' paul is not namespace qualified, while with the ` paul is. >> >> >> Turns out to be a bit of a pain, actually, although I have worked around >> it. But mostly I am surprised. Is this expected? > > Yes, this is very much expected! :

Re: Namespace qualification of symbols

2013-06-19 Thread Colin Fleming
Thank you for this, you just fixed a bug for me :-) I was trying to do some tricky type hinting with definline using amolloy's great answer on StackOverflow. Notice that he uses `BufferedImage and not 'BufferedImage. I stupidly figured that this was just a typ

Re: Namespace qualification of symbols

2013-06-19 Thread Leon Barrett
Yes, it's expected, and if you need unqualified names you need to carefully unquote and requote, e.g. (defmacro def-a-fn [body] `(defn ~'a-fn ;; you can only define unqualified names, I think [] ~@body)) On Wed, Jun 19, 2013 at 3:32 AM, Jim wrote: > On 19/06/13 09:46, Phillip Lord wrot

Re: Namespace qualification of symbols

2013-06-19 Thread Jim
On 19/06/13 09:46, Phillip Lord wrote: With the ' paul is not namespace qualified, while with the ` paul is. Turns out to be a bit of a pain, actually, although I have worked around it. But mostly I am surprised. Is this expected? Yes, this is very much expected! :) How else would you be abl

Namespace qualification of symbols

2013-06-19 Thread Phillip Lord
So, I was thinking that ' and ` were basically the same, unless a ~ was involved somewhere. But I have discovered this. (ns john) (println '(paul)) (println `(paul)) ;;=> (paul) (john/paul) With the ' paul is not namespace qualified, while with the ` paul is. Turns out to be a bit of a