In a namespace script I would like to use a couple of functions from the dfns workspace. However, if I do ⎕CY 'dfns'
all identifiers in dfns will be imported unqualified. How do I import dfns so that I can access functions in dfns with a qualifier, e.g. dfns.vtrim
? Do I first need to create a namespace named dfns?
Asked
Active
Viewed 64 times
1

Adám
- 6,573
- 20
- 37

August Karlstrom
- 10,773
- 7
- 38
- 60
1 Answers
1
You can import all of the dfns workspace into a namespace called dfns
with:
:Namespace Test
'dfns'⎕NS ⍬
dfns.⎕CY'dfns'
:EndNamespace
Test.dfns.pco ⍳10
2 3 5 7 11 13 17 19 23 29

Adám
- 6,573
- 20
- 37
-
As far as I understand, your example imports three functions into the namespace (script) Test. However, what I would like to do is to import the "identifier" *dfns* only and access the functions with *dfns* as a prefix/qualifier, e.g. `dfns.vtrim` or `dfns.pco`. The advantage of this approach is that I don't pollute the namespace and I can immediately tell where the functions in *dfns* come from. – August Karlstrom Feb 10 '20 at 11:39
-
@AugustKarlstrom Sorry about that. It should be correct now. – Adám Feb 10 '20 at 11:50