Thinking about package management, I came up with the following idea.
 Although I admit it is very simple-minded, thinking about it, it may be
all I need in most cases.

Requirements:

1.  All variable, function, and operator names within a single package must
start with package-short-name, and then a delta.  So, for example, within
my function editor package, all of my function and variable names would
begin with FE∆

2.  Each package is stored in its own workspace.

Given the above assumptions, I created functions to do the following:

    pkg Pkg∆Require ws

This copies ws if package pkg is not present.

    Pkg∆List

This returns a list of currently loaded packages

    z←Pkg∆Present pkg

return 1 if package pkg is present

    Pkg∆Erase pkg

Erases package pkg

Here is the function list:

    ∇ Pkg∆Erase pkg;t
[1]  t←⎕EX ((((1↑⍴t),(1+⍴,pkg))↑t)∧.=pkg,'∆')⌿t←⎕NL 2 3 4
    ∇


    ∇ r←Pkg∆List;t
[1]   ⍝ find names that have delta in them except in first column
[2]  r←,∧\'∆'≠t←(∨/'∆'=0 1↓t)⌿t←⎕NL 2 3 4
[3]  r←(⍴t)⍴(,' ',((×/⍴t),1)⍴t)[r+1+2ׯ1+⍳⍴r]
[4]   ⍝ right strip blank columns
[5]  ⍎'r←',((1=⍴⍴r)↑','),'(⌽∨\⌽'' ''∨.≠r)/r←((0,¯1↑⍴r)⍴'' '')⍪r'
[6]   ⍝ sort if necessary
[7]   ⍝ r←r[⍋r;]
[8]   ⍝ remove duplicate rows
[9]  r←(¯1↓1,∨/r≠1⊖r)⌿r
    ∇


    ∇ z←Pkg∆Present pkg;t
[1]  z←∨/(((1↑⍴t),(1+⍴,pkg))↑t←⎕NL 2 3 4)∧.=pkg,'∆'
    ∇


    ∇ pkg Pkg∆Require ws
[1]  ⍎(~Pkg∆Present pkg)/')COPY ',ws
    ∇


Simple as that.  True, it doesn't have any dependencies, but I either know
what they are, or I get told the first time I try to use it.

Sure, it's not the end-all for package management, it just suits many
simple cases.

Just sharing some thoughts.

Thanks.

Blake

Reply via email to