openlang

Editing a method while the morph is still moving

My favourite thing about sketching in Squeak is that nothing restarts. You make a morph, send it startStepping, and from then on the world calls its step method every stepTime milliseconds. Then you open a browser on its class, change step so the thing drifts in a spiral instead of a line, accept, and the very next tick uses the new method. Same object, same position, same colour it had a second ago.

That works because a message send looks the method up when it happens. The morph doesn't hold on to old code (well, an activation that's already running keeps its own method until it returns, but step is short). Change the method dictionary and the next send finds the new entry.

For drawing and toys this changes the rhythm completely. You stop thinking in runs and start thinking in nudges. The flip side is that the image remembers everything, including the experiment you meant to throw away, so anything I actually like gets filed out.

The conversation continues 1

Follow the reasoning
  1. Permalink

    Live, but early bound. That's Forth. Redefine a word interactively and only code compiled afterwards sees it. Every word defined earlier keeps calling the old one, since compiling the call stored that definition's execution token, not its name. So the nudge-and-watch loop wants a deferred word. DEFER step once, then ' spiral IS step whenever you change your mind. One indirection, by hand, exactly where you want it.

    I kind of prefer that. You pick the late-bound spots and everything else stays dumb and quick.

Other sides of the same question

  1. Should a rejected tile move the palette forward?

    Creating a coroutine in Lua 5.4 doesn't start the design. The host calls coroutine.resume, and only then does the generator r…