Copying all objects in a namespace

General APL language issues

Copying all objects in a namespace

Postby michaelk on Mon Dec 27, 2010 1:54 am

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?
michaelk
 
Posts: 22
Joined: Wed Feb 10, 2010 8:38 am

Re: Copying all objects in a namespace

Postby Phil Last on Mon Dec 27, 2010 10:48 am

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'
User avatar
Phil Last
 
Posts: 572
Joined: Thu Jun 18, 2009 6:29 pm

Re: Copying all objects in a namespace

Postby Phil Last on Mon Dec 27, 2010 10:54 am

Sorry missed ↑ or ⊃ for mix depending on ⎕ML
      ⎕SE.toBeCopied←'#.source.ns.'∘,¨#.source.ns.⎕nl-⍳10
                     ∧
at point of caret   
User avatar
Phil Last
 
Posts: 572
Joined: Thu Jun 18, 2009 6:29 pm

Re: Copying all objects in a namespace

Postby JohnS|Dyalog on Mon Dec 27, 2010 2:50 pm

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
JohnS|Dyalog
 

Re: Copying all objects in a namespace

Postby alexbalako on Mon Jan 03, 2011 6:29 pm

Now I am confused.
Why next will not work?
)cs Target
#.Target
)copy SourceWS Source.namespace
or:
'Source.namespace' Target.⎕CY 'SourceWS'
alexbalako
 
Posts: 16
Joined: Mon Nov 30, 2009 8:58 pm

Re: Copying all objects in a namespace

Postby Phil Last on Tue Jan 04, 2011 9:27 am

Because #.Target will end up containing namespace namespace rather than the contents of namespace.
User avatar
Phil Last
 
Posts: 572
Joined: Thu Jun 18, 2009 6:29 pm

Re: Copying all objects in a namespace

Postby alexbalako on Wed Jan 05, 2011 8:31 pm

Phil, I know the difference and not arguing with your solution, but wander if that is what was asked in original question :)
alexbalako
 
Posts: 16
Joined: Mon Nov 30, 2009 8:58 pm

Re: Copying all objects in a namespace

Postby Phil Last on Wed Jan 05, 2011 11:27 pm

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?
User avatar
Phil Last
 
Posts: 572
Joined: Thu Jun 18, 2009 6:29 pm


Return to Language

Who is online

Users browsing this forum: No registered users and 1 guest