Search code examples
namespaceskdbq-lang

KDB+ / Q Accessing root namespace from namespace


how can I access functions/variables in the root namespace once I jumped into another namespace.

Example like this:

q)\d .cfg
q)domIV:1000
q)\d .
q)n:1000

And then later on I know how to access the variable domIV from the other namespace, but I dont know how to access the variable n from there:

q)\d .seed
q).cfg.domIV / works
q)n          / does not work
q).n         / does also not work

How can I access the root namespace?

Thanks


Solution

  • Context (namespace) is just a dictionary so you can use dictionary syntax.

          q)  \d .seed
          q.seed)   `.[`n]
    

    Reference: http://code.kx.com/q4m3/12_Workspace_Organization/

    Check section: A Context is a Dictionary