Finding all the Stops


Stop and Trace are useful debugging tools, but sooner or later you want to take them out.  Which is easy enough, and Dyalog even build a toolbutton to clear all of the stops in the active workspace into the APL Session.  But what if you've forgotten where you set traps?  What if you want some cleared, but not all?  First task is to find what you have set, which is easy enough in an old, flat, workspace.  Things get a little more difficult if your workspace is made up of a hierarchy of nested namespaces.  Here's a utility that tours the entire workspace and reports what it finds by way of stops...

       ∇ z←stoplist w;⎕IO;⎕ML;nslist;stops;fnlist;stop;fn;ns
 ⍝ List of active stops
      ⎕IO ⎕ML←0 3
      z←''
      nslist←(⊂w),flatten namespacelist w
      :For ns :In nslist
          fnlist←(⊂ns,'.'),¨(⊂[1](⍎ns).⎕NL 3 4)~¨' '
          :If ×⍴fnlist
              stops←⎕STOP¨fnlist
              stops fnlist←(⊂∊×⍴¨stops)⌿¨stops fnlist
              :For (stop fn) :In (⊂¨stops),¨⊂¨fnlist
                  z,←(⊂fn),¨stop⊃¨⊂((1++\(⎕VR fn)∊⎕TC)⊂⎕VR fn)~¨⊂⎕TC
              :EndFor
          :EndIf
      :EndFor
      z←⊃z
    ∇

<namespacelist> works out what namespaces you have (in the purest sense of being a logical subdivision of the workspace)...

       ∇ z←namespacelist w;⎕IO;⎕ML
 ⍝ List of all namespaces
      ⎕IO ⎕ML←0 3
      z←''
      z←((⊂w,'.'),¨(⊂[1](⍎w).⎕NL 9)~¨' ')~''
      :If ×⍴z
          z,←(namespacelist¨z)~¨⊂''
      :EndIf
      z←z~⊂''
    ∇                    

While <flatten> turns this into a simple list...

   ∇ z←flatten w;⎕IO;⎕ML;item
 ⍝ Flatten a nested structure
      ⎕IO ⎕ML←0 3
      z←''     
      :For item :In w         
          :If 1=≡item             
              z,←⊂item         
          :Else             
              z,←flatten item
          :EndIf
      :EndFor
    ∇

Page created 6 April 2009.
Copyright © Dogon Research 2009.