Best way to declare a structure field that could be a function or a number

Yes, that’s how it’s usually handled.

But probably it’s best to go with function-only approach to avoid special cases, i.e.

struct Input{F<:Function,P<:AbstractFloat,O<:Signed}
    V0 :: F
     L :: P
     N :: O
end

Input(V0::Number, L, N) = Input(_->V0, float(L), Signed(N))
2 Likes