nothing, missing, and numbers ==0 have different semantics in Julia (which is a good thing). What you are asking for deviates from standard semantics, so you have to make your own choices and code them accordingly. The function above is a good way of doing this.
That said (and I hesitate to say this without more context) doing something like this in Julia is code smell.
@djsegal I recommend not considering typed zeros as unpresent values. The existence of an additive identity (we call that zero for Integers and some other structures), lets someone develop cascading and interacting logic that becomes this computer.
This should confer an awareness of the nonpresent.
function ispresent(x::T) where {P, T<:Union{Missing, Nothing, P}}
!(iismissing(x) || isnothing(x))
end
I don’t think this has any performance impact, I would be surprised if it did not compile to essentially the same code. I just like ≡ & friends visually, ismissing is fine.
I meant “Weird” in the sense of “I’ve never seen it before,” not “this is abhorrent to the natural order” . Thanks for explaining though so I don’t have to go digging once I get back to a computer