-
-
Notifications
You must be signed in to change notification settings - Fork 419
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
Arguing refcaps #4566
Comments
Ok so looking at this, there's a few things going on with what @hovsater is trying to do: First this works: use "collections"
class Foo is (Equatable[Foo])
let _numbers: Set[U32]
new create(numbers: Set[U32]) =>
_numbers = numbers
class Bob
let t: Map[U32, Set[U32]] = t.create()
fun ref apply(n: U32): Foo =>
let empty = Set[U32]
let a = t.get_or_else(n, empty)
Foo(a) But that isn't what @hovsater's code desugars to effectively. His lambda is creating a You can see a similar error from this simpler code: use "collections"
class Foo is (Equatable[Foo])
let _numbers: Set[U32]
new create(numbers: Set[U32]) =>
_numbers = numbers
class Bob
let t: Map[U32, Set[U32]] = t.create()
fun apply(n: U32): Foo =>
let empty = Set[U32]
let a = t.get_or_else(n, empty)
Foo(a) But that leads to a different issue with use "collections"
use "itertools"
class Foo is (Equatable[Foo])
let _numbers: Set[U32]
new create(numbers: Set[U32]) =>
_numbers = numbers
actor Main
new create(env: Env) =>
let container: Array[Foo] =
Iter[U32]([as U32: 1; 2; 3].values())
.map[Foo](
object ref
let t: Map[U32, Set[U32]] = Map[U32, Set[U32]]
fun ref apply(n: U32): Foo =>
let empty = Set[U32]
let a = t.get_or_else(n, empty)
Foo(a)
end)
.collect(Array[Foo]) |
@jemc I won't be around for the next sync, but I hope that I've left enough crumbs for this to start being discussed more fully. |
@hovsater noted in Zulip that |
i discussed with @jemc who knows Iter much better than I. This issue and similar is indeed why map_stateful exists. It is the proper solution. |
Alright. I'm still not entirely following why we need |
Let's chat at an upcoming Office Hours (I wont be there next week). I laid everything out above so I think it is an issue of walking through it together and answering questions. I'll be there on the 16th. |
Here's a quick summary from my end:
|
In this Playground example (also attached below),
table
have been captured by the lambda. The code does not compile, but I'm pretty sure it should. The issue was also shortly discussed on Zulip prior to this issue.Playground code
The text was updated successfully, but these errors were encountered: