Status of question mark syntax for missing values

For a while I was pretty ambivalent about whether we should use T? for Union{T, Nothing} or for Union{T, Missing}. The code I read and write has much more Union{T, Nothing} in it than Union{T, Missing}. However, I’ve come back around to wanting it to mean Union{T, Missing} for one very key reason: we need a way to express lifting of functions to the Union{T, Missing} domain. What I mean by that is that instead of every couple of days getting a new feature request for missing support for the atanh function or whatever, I’d like to just make atanh? lift the atanh function so that it returns missing when any of its arguments are missing. We don’t need this feature for nothing since the whole point of nothing is that it doesn’t lift, whereas the point of missing is to lift. We might also want a @? macro similar to the @. macro, which annotates all function calls with ? lifting.

How do f? and T? mesh? Quite well, actually, if you view the T constructor as a function that returns values of type T—then T? is a function that returns values of type Union{T, Missing} which is exactly what function lifting is supposed to do. Of course, you still want this to be represented as the union type, Union{T, Missing}, so you just need to make sure that the type, when called, does the lifted version of T. @jameson had some thoughts on this and might be able to say a bit more.

15 Likes