KX Community

Find answers, ask questions, and connect with our KX Community around the world.
KX Community Guidelines

Home Forums kdb+ set namespace on .q file

  • set namespace on .q file

    Posted by powerpeanuts on August 18, 2022 at 12:00 am

    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:{}

    powerpeanuts replied 9 months, 1 week ago 3 Members · 2 Replies
  • 2 Replies
  • cmccarthy1

    Member
    August 18, 2022 at 12:00 am

    Yes this can be done as follows

    // Move into namespace d .ns fn1:{} fn2:{} // Move out of namespace d .

  • cillianreilly

    Member
    August 18, 2022 at 12:00 am

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

     

     

Log in to reply.