[plt-scheme] Grafting a console onto universe, hackety hack.

From: Jordan Johnson (jmj at fellowhuman.com)
Date: Thu Jun 3 13:41:45 EDT 2010

On Thu, 3 Jun 2010, Matthias Felleisen wrote:
> I am wondering whether you could write a console that is a participant of a 'universe' and use a local server to connect the text field and the displayed text. But that's also like set! so it's too imperative.
>
> ;; ---
>
> In my spare time, I will think about parameterizing big-bang over the text/window field that it displays. I know it's doable in principle because classes are first-class and it could be a neat test case for just that reason.

For this case I could imagine something like:

     (big-bang/console world0
       (on-input-line handle-string) ;; handle-string : str -> result
       ...)                          ;; called when the user enters a line

where result = world
              | package
              | (make-output world str)
              | (make-output-package world str sexp)

in which the string arg to the last two constructors is a line of output to be
sent to the display, and all callbacks registered with big-bang/console
return a result as defined above.

What I don't like about that solution is the proliferation of return types.
And of course it isn't general.  But I'd expect that a form such as you're
talking about would provide good opportunities for discussion of classes and
interfaces with the students.  If I think of anything else (and can articulate
it in non-half-baked form), I'll let you know.

Thanks for your comments & consideration.

jmj


Posted on the users mailing list.