Skip to content

Smalltalk-style become: #229

@MostAwesomeDude

Description

@MostAwesomeDude

Reading old lore on become:, it seems that there's a possible design for one object to safely become another. We can use Promises as an example, since they are transparent forwarders. When a Promise becomes a value via resolution, it delegates all messages to that value, and returns all return values transparently. But any object could do this without Promises:

def becoming():
    var forwarding :Bool := false
    var ref := null
    return object willBecome:
        to run(x):
            return if (forwarding) { ref(x) } else {
                forwarding := true
                ref := x
            }
        match message ? (forwarding):
            M.callWithMessage(ref, message)

This suggests that there is a way to attenuate become: to tame it. An object can become another object precisely when it could choose to delegate all future messages to that object. We could imagine neatly wrapping this delegated ability within var patterns as name patterns for objects:

object var obj:
    to run(x):
        obj := x

This might only work when obj is passed by slot, though, which defeats the point.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions