Skip to content

Instantly share code, notes, and snippets.

@vito
Created August 8, 2010 01:29
Show Gist options
  • Save vito/513433 to your computer and use it in GitHub Desktop.
Save vito/513433 to your computer and use it in GitHub Desktop.
dispatch object + pseudo lisp-style parameterization
$ the
> foo := dispatch sender x
> foo
message not understood: (<reference> x)
> x = 0
> foo
0
> { x = 42; foo } call
42
> x
0
>
@vito
Copy link
Author

vito commented Aug 8, 2010

This should let me do some neat Scheme-style stuff like:

with-output-to: "foo.txt" do: {
    "hello!" write
    "using regular ol' write message" write
}

The idea being, write by default outputs to the terminal, but it's really determined by some current-output-port slot. Combined with lexical scoping via blocks, and the dispatch form which gives access to the sender's scope, we can safely "override" that value just for that scope.

Also: yes, this is pretty much directly from Io - in fact almost all of their Call objects' slots have a direct correlation to something in The as well. Neat. (The odd one out being call target - in The a dispatch may have many targets.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment