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

Ptr <: Ref #28806

Closed
distractedlambda opened this issue Aug 21, 2018 · 1 comment
Closed

Ptr <: Ref #28806

distractedlambda opened this issue Aug 21, 2018 · 1 comment
Assignees

Comments

@distractedlambda
Copy link

distractedlambda commented Aug 21, 2018

I was surprised to find out that Ptr{T} <: Ref{T}. I'm guessing that there's a reason for this, but it complicates a key conceptual aspect of Refs:

This type is guaranteed to point to valid, Julia-allocated memory of the correct type. The underlying data is protected from freeing by the garbage collector as long as the Ref itself is referenced.

Granted, the above statement remains true for anything constructed with Ref(...), but the problem remains that something which, under the type system, is a Ref{T}, could violate those guarantees by concretely being a Ptr{T} (as opposed to e.g. a Base.RefValue{T}).

@vtjnash
Copy link
Member

vtjnash commented Apr 17, 2019

Addressed by #31700

@vtjnash vtjnash closed this as completed Apr 17, 2019
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

2 participants