Is there anything that uses the Inspector (ObjectInspector etc.) classes?

These (undocumented) classes generate some gui elements presumably for some kind of visual debugger e.g.

(foo: 4).inspectorClass.new

But they don’t seem to quite work (as in show much). Is this some kind of abandoned project or am I missing the proper way use them?

Ah, I actually needed to do

e = (foo: 4);
e.inspectorClass.new(e); // or just
e.inspect; // ok too

to get them to work.

Also you can inspect methods

m = e.class.findRespondingMethodFor(\putAll);
m.inspectorClass.new(m); // ok
m.inspect // err: this doesn't' work directly though 

And a stack frame, although getting it is a bit different

f = {|x| this.getBackTrace.inspect; x + 3; }
f.(2);

I also see there’s an undocumented classvar debug in Error, which if set to true will automatically trigger some inspect calls when an error happens. So I guess this is the level of automation provided.

Quick and dirty stepping debugger:

c = Condition(false);
~breakpoint = {|cnd| var bt = this.getBackTrace.caller; { bt.inspect }.defer; cnd.wait; cnd.test = false }

{ var x = 1, y; "one".postln; ~breakpoint.(c);  y = 2; "two".postln; ~breakpoint.(c); }.fork;

c.test = true; c.signal; // used to step

If it’s interesting, here’s a more modern implementation:

This requires Quarks.install("https://github.com/scztt/WindowViewRecall.quark").

1 Like