Comparing functions in namespace/class scripts

APL-related discussions - a stream of APL consciousness.
Not sure where to start a discussion ? Here's the place to be
Forum rules
This forum is for discussing APL-related issues. If you think that the subject is off-topic, then the Chat forum is probably a better place for your thoughts !

Comparing functions in namespace/class scripts

Postby ray on Fri Aug 03, 2018 7:02 pm

With classic functions in a workspace, I can easily find out which (and when) functions have been changed by their timestamps. So I can quickly identify functions updated between version by the save workspace date and the function time stamp.

Under APL control, given two (or more) versions of a namespace scripts, how can I easily identify which functions in the scripts have been modified, added or deleted between the versions?

Is there a user command perhaps?
Ray Cannon
Please excuse any smelling pisstakes.
User avatar
ray
 
Posts: 137
Joined: Wed Feb 24, 2010 12:24 am
Location: Blackwater, Camberley. UK

Re: Comparing functions in namespace/class scripts

Postby Adam|Dyalog on Mon Aug 06, 2018 5:28 pm

It you save every function in its own file, SALT can keep track of their time stamps for you:

      ]settings track atinfo
atinfo
⎕TS⊣⎕FX'fn' '42'
2018 8 6 18 26 5 282
]save fn /tmp/
\tmp\fn.dyalog
⎕DL 30
]load \tmp\fn.dyalog
fn
2⊃⎕AT'fn'
2018 8 6 18 26 5 0
⎕TS
2018 8 6 18 27 7 790


Note that this only works for tradfns and tradops.
User avatar
Adam|Dyalog
 
Posts: 52
Joined: Thu Jun 25, 2015 1:13 pm

Re: Comparing functions in namespace/class scripts

Postby Phil Last on Mon Aug 06, 2018 8:56 pm

Ray

Your question makes me think you've been lucky enough not to have had many dealings with scripted spaces.

So you may not be aware that given a scripted space "myscript" you can request myscript.⎕nl 3 4 and given a function "myscript.myfunction" you can request its ⎕CR/⎕VR/⎕NR independently of the script as [say] myscript.⎕cr'myfunction'

So copying your versions from their source workspaces into different spaces ns1 and ns2 the intersect of functions is
      int←⊃∩/(ns1 ns2).myscript.⎕nl ¯3
. And given the requisite number of encloses and eaches you can compare
      (ns1 ns2).myscript.(⎕NR¨)⊂int
And the two complements, the additions and deletions, will be
      ⊃~/(ns1 ns2).⎕nl ¯3
and
      ⊃~/(ns2 ns2).⎕nl ¯3
But given all that if you look at the APLTree library you'll probably find that Kai has already written exactly want you need.
User avatar
Phil Last
 
Posts: 485
Joined: Thu Jun 18, 2009 6:29 pm

Re: Comparing functions in namespace/class scripts

Postby ray on Tue Aug 07, 2018 11:48 am

Adam and Phil, thanks for your replied.

Adam,
My problem is that I have NOT written the scripted namespaces, so your idea of saving each function in its own file simply does not apply.
But if I do want to store functions via SALT I will certainly do exactly that.
I did something similar under mainframe STSC APL, and stored the timestamp in a trailing comment automatically whenever the function was updated.

Phil.
Your so right, I do avoid scripts whenever I can!

However I cannot avoid them when dealing with classes, and I have to use classes when using MiServer.

So for my own MiServer "Class" script, all my functions are stored under a namespace in a classic workspace, and included in the class vis:

Code: Select all
:Class hex : MiPage
    :Include #.hex_fns     
    :field public event     ⍝ the triggered event - JQ.On supplies this
    :field public what      ⍝ the id of the element that triggered the  event
    :field public _Request
<snip> ...... </snip> 
    :Field FileData   ← 0
    :Field red_ant_brain←''
    :Field black_ant_brain

:EndClass

So my scripted namespace/class contains no functions, and my functions in a classic namespace, all have standard timestamps.
The only minor problem is the namespace containing the functions, needs to exist in the workspace BEFORE the class is loaded into that workspace.

Your tips on comparing the functions via different namespaces are very useful. Thank you.
I have been comparing whole workspaces (back to Dyalog V7) by loading a second workspace into a temp namespace under ⎕SE with some utility tools. Combining these tools with your tips, will I think "do the job".

Thanks to both of you once again for all your useful ideas.

Ray
Ray Cannon
Please excuse any smelling pisstakes.
User avatar
ray
 
Posts: 137
Joined: Wed Feb 24, 2010 12:24 am
Location: Blackwater, Camberley. UK


Return to APL Chat

Who is online

Users browsing this forum: No registered users and 1 guest