3 ms·
How does message passing work with a statically-typed language? (Genuine question, not criticism.) My understanding is that Smalltalk-style message passing's ma
by ar-nelson 6y ago
How does message passing work with a statically-typed language? (Genuine question, not criticism.) My understanding is that Smalltalk-style message passing's main advantage is that it allows handing or proxying unknown method calls, but unknown method calls are forbidden in a static type system.
- weatherlight 6y agoMake objects Actors (as per the Actor model of computation). You don't call methods on objects, you pass a message to their mailboxes, Objects then choose how to process those messages. To do this though, messages would have to be immutable.
- ar-nelson 6y agoGiven a static type system that constrains the kinds of messages you can send, their arguments, and their response types, how is this meaningfully different from normal method calls? My understanding is that message-passing only starts to have interesting consequences when you do dynamically-typed things.
- weatherlight 6y agoyou could design the mailbox to accept all messages, how the object handles those messages is a separate concern, you could use something like multiple dispatch to then decide which method on the object gets the message. Gleam is a statically typed language on the BEAM, early implementations the messages between processes were not typed, Im not sure if that still the case. Pony is a OO language thats based on the Actor model that has a strong static type system, where typed message passing is central to the language.