Copying all objects in a namespace
Copying all objects in a namespace
Probably a silly question, but if I wish to copy all objects in a namespace in workspace W to a namespace in a different workspace X is there a simple way to do this?
Re: Copying all objects in a namespace
michaelk wrote:Probably a silly question, but if I wish to copy all objects in a namespace [#.source.ns] in workspace W to a namespace [#.target.ns] in a different workspace X is there a simple way to do this?
You could try this; I'm afraid I've had time to test it only once right now.
)XLOAD W
⎕SE.toBeCopied←'#.source.ns.'∘,¨#.source.ns.⎕nl-⍳10
)XLOAD X
⎕SE.toBeCopied #.target.ns.⎕CY 'W'
Re: Copying all objects in a namespace
Sorry missed ↑ or ⊃ for mix depending on ⎕ML
⎕SE.toBeCopied←'#.source.ns.'∘,¨#.source.ns.⎕nl-⍳10
∧
at point of caret
⎕SE.toBeCopied←'#.source.ns.'∘,¨#.source.ns.⎕nl-⍳10
∧
at point of caret
Re: Copying all objects in a namespace
This alternative uses essentially the same method as Phil's:
)xload X
...
)copy dfns refws
...
(refws'W').source.('#.target' ⎕ns ⎕nl ⍳10)
)erase refws
See http://www.dyalog.com/dfnsdws/n_refws.htm
)xload X
...
)copy dfns refws
...
(refws'W').source.('#.target' ⎕ns ⎕nl ⍳10)
)erase refws
See http://www.dyalog.com/dfnsdws/n_refws.htm
-
- Posts: 16
- Joined: Mon Nov 30, 2009 8:58 pm
Re: Copying all objects in a namespace
Now I am confused.
Why next will not work?
)cs Target
#.Target
)copy SourceWS Source.namespace
or:
'Source.namespace' Target.⎕CY 'SourceWS'
Why next will not work?
)cs Target
#.Target
)copy SourceWS Source.namespace
or:
'Source.namespace' Target.⎕CY 'SourceWS'
Re: Copying all objects in a namespace
Because #.Target will end up containing namespace namespace rather than the contents of namespace.
-
- Posts: 16
- Joined: Mon Nov 30, 2009 8:58 pm
Re: Copying all objects in a namespace
Phil, I know the difference and not arguing with your solution, but wander if that is what was asked in original question :)
Re: Copying all objects in a namespace
I see what you mean. I guess if it doesn't matter what the resultant namespace is called then the straightforward solution fulfils the requirement. We can always create a global ref with the name of our choice.
In fact moving items from one space to another with a different name can have repercussions if the code makes use of named refs be they absolute or relative. So it's probably safer if it is the same.
The way APL# is going it looks as though at some time in the future we won't have the choice. All refs to a space will be equally the "actual" space their having no fixed abode. Just as #.thisSpace.(3) and #.thatSpace.(3) refer to the same number 3. Or do they?
In fact moving items from one space to another with a different name can have repercussions if the code makes use of named refs be they absolute or relative. So it's probably safer if it is the same.
The way APL# is going it looks as though at some time in the future we won't have the choice. All refs to a space will be equally the "actual" space their having no fixed abode. Just as #.thisSpace.(3) and #.thatSpace.(3) refer to the same number 3. Or do they?