As you might have noticed, parametrically defined functions, e.g. functions like foo{T}(x), can only be defined if they are constructors for a type (which has already been defined). What you can do instead is take the desired output type as a function argument, like this:
struct Output{T <: Number}
other_details::String
numeric_output::T
end
function get_output(::Type{T}, input) where {T <: Number}
Output("lots of data", T(input))
end
julia> get_output(Float64, 1)
Output{Float64}("lots of data", 1.0)
Note that a literal 1 is already an integer. There's no need to write 1::Int64.
Also note the use of a singleton type in the function signature. This only serves to restrict the dispatch. You could write get_output like this and it would work fine:
get_output(T, input) = Output("lots of data", T(input))
By the way, I would strongly recommend against doing this, but it is possible to cheat, since the Julia compiler does not enforce that constructors actually return instances of the types that they are supposed to construct:
struct Output{T <: Number}
other_details::String
numeric_output::T
end
struct get_output{T} end
function get_output{T}(input) where {T <: Number}
Output("lots of data", T(input))
end
julia> get_output{Float64}(1)
Output{Float64}("lots of data", 1.0)