My instinct is to write a macro.
On Tuesday, July 21, 2015 at 4:37:03 PM UTC-4, Darwin Darakananda wrote: > > Hi all, > > I'm in the process of replacing my Union{Nothing, T} annotations to > Nullable{T}, but I'm getting stuck when T is a parametric type. For > example, replacing the function > > function myfunc(v::Union{Nothing, Vector}) > ... > end > > with > > function myfunc(v::Nullable{Vector}) > ... > end > > makes it completely uncallable since any vector I pass in comes with an > eltype parameter and Julia's type parameters are invariant. For functions > or types that only have a couple Nullable types, I can do something like > > function myfunc{T}(v::Nullable{Vector{T}}) > ... > end > > type MyType{T} > v::Nullable{Vector{T} > end > > but that gets very ugly when you have a large number of nullable types. > Does anyone know of a cleaner way to do this? > > Thanks, > > Darwin >