Excluding variables at namespace granularity

SALT, SPICE, Subversion, etc...

Excluding variables at namespace granularity

Postby neeraj on Sat Aug 02, 2014 7:25 pm

I am using the following command to capture a namespace to a script

[]SE.SALT.Save #.CLAIMS '[ws]/OpenClaims'


The namespace contains some global variables that are constantly changing. How can I exclude variables to be written to the script.
neeraj
 
Posts: 77
Joined: Wed Dec 02, 2009 12:10 am
Location: Ithaca, NY, USA

Re: Excluding variables at namespace granularity

Postby DanB|Dyalog on Sun Aug 03, 2014 8:51 pm

SALT.Save simply writes out the namespace as it is.
Is it possible to remove the variables using ⎕EX? e.g.
Code: Select all
    #.Claims.⎕ex ListOfVarsToExpunge
    ⎕SE.SALT.Save '#.CLAIMS [ws]/OpenClaims'
DanB|Dyalog
 

Re: Excluding variables at namespace granularity

Postby neeraj on Sat Aug 16, 2014 5:18 am

Not Really. It would significantly increase the overhead involved each time I wanted to save the namespace script.
neeraj
 
Posts: 77
Joined: Wed Dec 02, 2009 12:10 am
Location: Ithaca, NY, USA

Re: Excluding variables at namespace granularity

Postby Phil Last on Sat Aug 16, 2014 5:04 pm

      )clear
clear ws

⍝ dfns: notes is full of arrays
      )copy dfns notes
C:\Program Files\Dyalog\Dyalog APL-64 14.0 Unicode\ws\dfns saved Sat Jun 28 08:57:24 2014
⍝ now copy the entire ws into notes
      notes.⎕cy'dfns'
,∘≢⌸notes.(⎕nc⎕nl-⍳10)
2.1 61
4.2 64
3.2 197
9.1 2
notes.⎕nl 9
notes
scripts
⍝ get rid of the spaces
      notes.(⎕ex⎕nl 9)
,∘≢⌸notes.(⎕nc⎕nl-2 3 4)
2.1 61
4.2 64
3.2 197

⍝ we have a ns with vars fns & ops
⍝ the vars happen to be those not obscured by fns or ops of the same name.
⍝ All that was just creating the test environment.
⍝ Now run this function:
      ∇f00←{⍺←⊢
[1] file←⍺
[2] space←⍵
[3] hidden←space.(⎕NS ⎕NL 2.1)
[4] z←space.(⎕EX ⎕NL 2)
[5] z←⎕SE.Salt.Save space file
[6] 'space'⎕NS'hidden.',⍤1⊢hidden.⎕NL 2
[7] ⍝ ⍺ file
[8] ⍝ ⍵ space
[9] }

'c:\users\phil\desktop\notes' f00 notes
,∘≢⌸notes.(⎕nc⎕nl-2 3 4)
2.1 61
4.2 64
3.2 197

⍝ now in another session:

      )clear
clear ws
⎕SE.SALT.Load'c:\users\phil\desktop\notes.dyalog'
,∘≢⌸notes.(⎕nc⎕nl-⍳10)
9.1 1
4.2 64
3.2 197
notes.⎕nl 9
SALT_Data
⍝ look! no vars!

⍝ Works fine but if anything goes wrong on line five or six
⍝ and the stack is cleared I'm afraid you've lost the lot!
⍝ A bit like juggling I suppose.
User avatar
Phil Last
 
Posts: 441
Joined: Thu Jun 18, 2009 6:29 pm

Re: Excluding variables at namespace granularity

Postby DanB|Dyalog on Sat Aug 16, 2014 9:22 pm

Phil's program would work except for line 5 which should read
z←⎕SE.SALT.Save space file

You could put f00 permanently in your ⎕SE or, better yet, write a user command to do the same.
DanB|Dyalog
 

Re: Excluding variables at namespace granularity

Postby Phil Last on Sat Aug 16, 2014 11:05 pm

Quite right Dan. I remember now I had to fix it in mid flow after copying piecemeal to a text file (easier than composing it in the browser). Then I copied it to the browser without the change!!!
User avatar
Phil Last
 
Posts: 441
Joined: Thu Jun 18, 2009 6:29 pm

Re: Excluding variables at namespace granularity

Postby Phil Last on Sun Aug 17, 2014 9:01 am

      ∇f00←{⍺←⊢
[1] file←⍺
[2] space←⍵
[3] new←'#.n',⍕{⊣/(⍳1+⍴⍵)~⍵}∪⊃{⍺/⍵}/⎕VFI,' ',0 1↓'n'#.⎕NL⍳10
[4] z←new{⍎⍺,'←⍵'}hidden←space.(⎕NS ⎕NL 2.1)
[5] z←space.(⎕EX ⎕NL 2)
[6] z←⎕SE.SALT.Save space file
[7] z←'space'⎕NS'hidden.',⍤1⊢hidden.⎕NL 2
[8] ⎕EX new
[9] ⍝ ⍺ file
[10] ⍝ ⍵ space
[11] }

added lines [3,8] and amended [4] ensure that there is a copy of the vars in previously non-existent root space #.nNN if an error is )RESET. The new space is expunged as a last operation if all is well.
User avatar
Phil Last
 
Posts: 441
Joined: Thu Jun 18, 2009 6:29 pm


Return to Source Code Management

Who is online

Users browsing this forum: No registered users and 1 guest