-
Notifications
You must be signed in to change notification settings - Fork 62
use nothing instead of Nullable #90
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
Conversation
src/GitHub.jl
Outdated
using Compat | ||
using Nulls | ||
|
||
const ?{T} = Union{T, Null} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is maybe too cute...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought we got rid of the ability to do that on master? I think DataArrays calls this union Data{T}
internally as a stopgap until we get T?
in Base.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you use Void
as I suggested, HTTP has this definition:
const Option{T} = Union{T, Void}
then defines internal fields and whatnot in terms of Option
.
Since |
I had thought the Apologies for my confusion - the whole |
The idea is that The other use case for missing data is the "software engineer's null," which does not propagate and is intended to stop computations by throwing a Admittedly the situation is quite confusing. I think in this case it would be good to follow the precedent set in HTTP, which uses |
Ah, that makes sense, thanks. You're right, the "software engineer's null" is definitely want we want here. It seems like the best path forward, then, would be to avoid the However, if the |
baed66f
to
41fd2f9
Compare
using Base64 | ||
end | ||
|
||
const ?{T} = Union{T, Nothing} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is allowed on 0.7. IIRC Carlo Baldassi submitted a PR that removes the parsing of ?
as an identifier.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you want a shorthand for Union{T, Nothing}
, I recommend something like Maybe{T}
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I'll change this.
I would advise against adding another kind of null type, i.e. |
Done on master by @staticfloat |
Not having to unpack every value you want to get at is quite convenient. I think this is worth it.