-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Nullable(0, true) !== Nullable{Int}() false #16923
Comments
Related: #9147 |
Without something like #9147, this seems hard to me. The current semantics of |
No doubt |
I'm not aware of one. I wish we had a mechanism for doing that in general, but I don't see how to pull it off while preserving immutability. The only thing I can imagine is that we could provide a mechanism for asking for a pseudo-value that is equivalent to a bit pattern that's filled with zeros and has the right memory size. |
Zero-filling will have to also be implemented in a good amount of C code that bypasses the default constructor. I don't know if it's a good idea. Also, a good chunk of NullableArray's autolifted code seems optimized to avoid branches on operations. Some of these operations are broken anyway (filed JuliaStats/NullableArrays.jl#116), but it's conceivable to imagine that some could produce non-zero results. |
Also note that this is similar to |
@TotalVerb Zero filling can be provided by the memory allocator, at a level of abstraction below constructors. Yes, several places in the C runtime code will have to be updated, but I don't see a problem with that. |
I'm starting to think this behavior isn't really a problem. Should we close the issue then? |
Fine by me. |
Title says it all. It's possible to create two objects which are printed as
Nullable{Int}()
and are not supposed to differ in any way, and yet are actually different according to===
. This is because:This is particularly annoying when writing tests, but it can also be disturbing in real uses.
For non-
isbits
types, a solution is to discard the value in the constructor whentrue
, i.e.:But this doesn't work for
isbits
types, for which the field contains random values when left uninitialized. I guess there's a way to fill thevalue
field with zeros à lareinterpret
, but what's the best way to do it?Cc: @johnmyleswhite
The text was updated successfully, but these errors were encountered: