Getproperty, decorations, inheritance in 0.7

How about if I want to dynamically specialise on a certain value?

using StaticArrays

function f(n::Int)
    b = rand(SVector{n})
    for i in 1:10000
        b += rand(SVector{n})
    end
    return b
end

function f(_n::Val{n}) where n
    b = rand(SVector{n})
    for i in 1:10000
        b += rand(SVector{n})
    end
    return b
end

g1() = f(rand(4:4))
g2() = f(Val(rand(4:4)))

@time g1()
@time g2()
julia> @time g1();
  0.015060 seconds (140.02 k allocations: 8.851 MiB)

julia> @time g2();
  0.000249 seconds (5 allocations: 208 bytes)
10 Likes