⍝ Space reference match:

    'xy'⎕ns¨⊂'' ⊣x y←0              ⍝ distinct spaces x and y.

    x refmatch x                    ⍝ space matches self.
1
    x refmatch y                    ⍝ distinct spaces match.
1
                                    ⍝ populate with:
    (x y).(⎕io ⎕ml num)←⊂1 2 3      ⍝   vars,
    (x y).(⎕fx'z←sum v' 'z←+/v')    ⍝   function,
    (x y).(z←⎕ns'')                 ⍝   space.
    (x y).z.(⎕io ⎕ml num)←⊂0 1 3    ⍝ populate subspace.

    x refmatch y                    ⍝ spaces match.
1
    x.z.num←3                       ⍝ replace with same value.
    x refmatch y                    ⍝ still match.
1
    x.z.num←4                       ⍝ replace with distinct value.
    x refmatch y                    ⍝ mismatch.
0

    ⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝ Cycles:

    x y←⎕ns¨'' '' ⊣x y←0            ⍝ ┌←┐     ┌←┐   refs to parent: match
                                    ⍝ x─│─┐   y─│─┐
    (x y).z ← x y                   ⍝ │ z │   │ z │
    x refmatch y                    ⍝ └───┘   └───┘
1
                                    ⍝   ┌─→─#─←─┐   refs to common ancestor
                                    ⍝ x─│─┐   y─│─┐
    (x y).z ← #                     ⍝ │ z │   │ z │
    x refmatch y                    ⍝ └───┘   └───┘
1
                                    ⍝ ┌←┬──────←┐   refs to same space
                                    ⍝ x─│─┐   y─│─┐
    (x y).z ← x                     ⍝ │ z │   │ z │
    x refmatch y                    ⍝ └───┘   └───┘
1
                                    ⍝     ┌──←──┐   cross-refs to aunt/uncle
                                    ⍝ ┌───x   ┌─│─┐
                                    ⍝ │ z │   │ z │
    (x y).z ← y x                   ⍝ └─│─┘   y───┘
    x refmatch y                    ⍝   └──←──┘
1

⍝∇ refmatch

Back to: code

Back to: Workspaces