... until the collector arrives ...

This "blog" is really just a scratchpad of mine. There is not much of general interest here. Most of the content is scribbled down "live" as I discover things I want to remember. I rarely go back to correct mistakes in older entries. You have been warned :)


Actors... Dynamic Typing Redux?

I was reading the chapter in Programming In Scala that introduces actors.  It noted that it is a good idea to use named types for messages as opposed to basic types like tuples, arrays and lists.  This makes it easier to locate an actor who could possibly process the message.  Sound advice.  However, I was struck by the fact that if you expose Actors as part of an API, that part becomes effectively untyped (or "duck typed" in popular parlance).

I was struck further by the fact that almost all of the Erlang code to which I have been exposed uses tuples with wild abandon.  Of course, Erlang is mostly untyped so that should be no surprise.  Scala, at least, offers machinery to prevent dynamically typed signatures from escaping a module boundary (for example, by making sure an implementation has-a actor instead of is-a actor).

As a final bit of irony, I observe that Smalltalk's message selector syntax offers a pretty decent solution for identifying objects that can handle (synchronous) messages -- provided you choose a name more distinctive than at: or at:put:.  The irony lies in the fact that Smalltalk is frequently held up as the prototype for duck-typing.  I wonder if Smalltalk's message selector syntax arose to solve the very problem of searching for methods?

Blog Archive