Open marzipankaiser opened 2 months ago
(Of course, feel free to add/edit/make sub-issues etc)
I'd like to be able to allocate an object into a region (if it has mutable state).
new Foo(x, y) in {r}
or maybe
interface Foo {
def op(): Unit
}
class Bar {r: Region} implement Foo {
var field in r = 4
def op() = {
r = r + 1;
this.helper() // it should be possible to invoke methods on the same object
}
// NOT part of the interface
def helper() = println(r)
}
new Bar {global}
I'd like to be able to allocate an object into a region (if it has mutable state).
Would it also make sense to allocate a capability into a region? 🤔
(so that the return type is Counter at {r}
)
def makeCounter {r: Region} = {
var count in r = 0
try {
println(c.get())
c.increment()
c.increment()
println(c.get())
c
} with c: Counter in r {
// ~~~^
def get() = resume(count)
def increment() = { count = count + 1; resume(()) }
}
}
In general, we need to rethink / redesign the "object-system" anyways. Some aspects are:
See also