Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Smalltalk-style become: #229

Open
MostAwesomeDude opened this issue Mar 27, 2021 · 0 comments
Open

Smalltalk-style become: #229

MostAwesomeDude opened this issue Mar 27, 2021 · 0 comments

Comments

@MostAwesomeDude
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant