scopingutilityapldyalog

Dyalog APL, how to have utilitiy functions available in workspace but not mixed in with other functions


I have a couple utilities written in APL (clear screen and edit function in external editor VIM). I wondering what is the best way to load them into my "working" workspace but not have them mixed into my other code. I don't want to )copy them as that will be make updates difficult.

I was looking at using a namespaces but docs say they will run in their own NS which means the functions in "working" NS is not easily available to write to a file and pass a copy to vim.

This has to be a common issue. Any suggestions??


Solution

  • Two solutions, but both involve additional typing, though there's an aid to that:

    1. Place them in ⎕SE — although that is a different namespace, so you'd have to write ⎕SE.MyUtil (or better, ⎕SE.myUtils.MyUtil) instead of MyUtil.

    2. Make them into user commands — so you'd write ]MyUtil instead of MyUtil but for the function editing, you can avoid having to type quotes around the name.

    In either case, you bump into the issue of reaching the space your utility was called from. This is easily solveable, however: For a utility function, use ⊃⎕RSI and for a user command, use ##.THIS.

    By the way, you can assign an F-key to insert the utility names into the session, saving you some typing. The F-key can even press Enter for you. For example, do ('⎕SE.MyUtil',⊂'ER')⎕PFKEY 4 to run ⎕SE.MyUtil upon pressing F4.

    (Ask a new question if you need help to do any of the above.)