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
Currently, references can be invalidated by invalidating their origin inside their scope.
(defnuse-up [x] ())
(defnmain []
(let-do [a [@"hi"]
n (Array.nth &a 0)]
(use-up a)
(println* n))) ; we used a already! this is bad!
It is also possible to set references to point to values in a more short-lived scope:
(defnmain []
(let-do [x ""]
(let [a [@"hi"]]
(set! x (Array.nth &a 0)))
(println* x))) ; a was already dropped!
Both of these can be prevented by checking the origin of a reference and whether the origin scope still exists; an error could be emitted if it doesn’t.
Cheers
The text was updated successfully, but these errors were encountered:
maybe data structures like Array should be able to take ownership (or have ownership automatically transferred to it when it has a reference to a variable that goes out of scope and would otherwise be deallocated) ?
Currently, references can be invalidated by invalidating their origin inside their scope.
It is also possible to set references to point to values in a more short-lived scope:
Both of these can be prevented by checking the origin of a reference and whether the origin scope still exists; an error could be emitted if it doesn’t.
Cheers
The text was updated successfully, but these errors were encountered: