questions on namespace referencing when using \d

Hi Folks,

I have a basic question encountered doing Level 3 - Namespace - Practical Questions.

how exactly is the grammar for referencing namespace with \d?

  1. get method

c:3 
\d .test
a:1
b:2
f1:{a+b+ get `..c}
f2:{a+b+ `.[`c]}
\d .

my questions are:

1. why get method requires two dots for param c?
2. why `.[`c] requires one dot?
3. why `.[`test1][`a] doesn't work, if .test1.a exist, but only `.test1.a would work?

Thank you!

  1. The reference `..var is analogous to `.ns.var, only in this case the namespace has no name after the dot. This is a special namespace that can only be used by making it the current namespace (which is the case when you start the q process and after doing \d .), or by using symbols like in these examples.
  2. The symbol `. refers to the entire blank-named namespace. Therefore by indexing it you already get the namespace itself, from which you select the variable indicated by the index. This is equivalent to `.ns[`var], once again changing it so that there are no characters after the dot in the namespace name.
  3. `.[`test1] would refer to a variable named `test1 in the blank-named namespace. This is not the same as the .test1 namespace, since namespaces are not children of the blank-named namespace.