cancel
Showing results for 
Search instead for 
Did you mean: 

set namespace on .q file

powerpeanuts
New Contributor III

hi, on a .q file, how can I set the namespace (e.g. ns), so that I do not have to specific the namespace every time when defining a function?

Instead of:

.ns.fn1:{}

.ns.fn2:{}

 

Can we have something like:

(set namespace ns)

fn1:{}

fn2:{}

1 ACCEPTED SOLUTION

cmccarthy1
New Contributor III
New Contributor III

Yes this can be done as follows

// Move into namespace
\d .ns

fn1:{}
fn2:{}

// Move out of namespace
\d .

View solution in original post

2 REPLIES 2

cmccarthy1
New Contributor III
New Contributor III

Yes this can be done as follows

// Move into namespace
\d .ns

fn1:{}
fn2:{}

// Move out of namespace
\d .

cillianreilly
New Contributor III

Yes, this is possible using the system command "d". See here for more info: https://code.kx.com/q/basics/syscmds/#d-directory

 

q)\d .ns
q.ns)fn1:fn2:{}
q)\d .
q).ns
   | ::
fn2| {}
fn1| {}