You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If there was a func _next[T](list: List[T]) -> Ref[None|Ref[Node[T]], you could use it for insertion:
func insert[T](list: List[T], value: T) {
new_node: Ref[Node[T]] =? new(Node(value, None())) # not collapsing, i.e. keeping the Ref #
_next(list) =? new_node # assign the Ref[Node[T]] into the None|Ref[Node[T]] reference returned by `_next`
}
Here with =? I mean some operator not implemented yet.
We have two cases here:
Local[Ref[T]] = Ref[T]
Ref[Ref[T]] = Ref[T]
I think case 1 is simple to solve: We can add a "do not collapse" operator, which collapses all Ref, but not the local variable reference (here: Local).
Case 2 is more difficult: We want to collapse one layer of the Ref, but not the other one. In general, for assignments, you would want only the single, most outer Ref to collapse. I'm not sure yet how to handle that.
The text was updated successfully, but these errors were encountered:
For example to implement a linked list, you could define
If there was a
func _next[T](list: List[T]) -> Ref[None|Ref[Node[T]]
, you could use it for insertion:Here with
=?
I mean some operator not implemented yet.We have two cases here:
Local[Ref[T]] = Ref[T]
Ref[Ref[T]] = Ref[T]
I think case 1 is simple to solve: We can add a "do not collapse" operator, which collapses all
Ref
, but not the local variable reference (here:Local
).Case 2 is more difficult: We want to collapse one layer of the
Ref
, but not the other one. In general, for assignments, you would want only the single, most outerRef
to collapse. I'm not sure yet how to handle that.The text was updated successfully, but these errors were encountered: