Sunday, September 10, 2006

Visualizing stack code

I implemented a nifty hack today:

It still looks ugly (both in presentation and code) and needs some tweaks.

3 comments:

Anonymous said...

I looked at that and thought about Map: Forth in 3D.

http://mythago.net/map0.html

Although, I don't think the two models match very closely. It is still that visual aspect that caught me.

Anonymous said...

Two thoughts: Is rot 1 + rot 2 + rot 3 + >r / r> * a useful word, and is a visual stack a useful tool?

I'd say no to both. The visual stack is cool, and kudos for showing it. But why would you need to illustrate the stack effect of a well-factored word?

Slava Pestov said...

The tool can help people first learning Factor, and it can also help Factor programmers understand how the compiler optimizes code.

The tool's display is actually the dataflow IR the optimizer spits out when fed a quotation. Previously I would use the inspector in the listener to navigate the IR. This is not that bad, but a graphical view is more fun.

This is similar in spirit to Forth implementations that provide disassemblers.

In darcs, the tool is well integrated, you just type a quotation in the listener and press Ctrl+Alt+d.