Julep: Efficient Hierarchical Mutable Data

This seems very similar to how views work on vectors:

f(v::Vector) = sum(v)

v = collect(1:10)
vv = view(v, 2:3)

f(v) # 55
f(vv) # ERROR: MethodError: no method matching f(::SubArray{Int64, 1, Vector{Int64}, Tuple{UnitRange{Int64}}, true})

For views, the solution is typically to use AbstractVector rather than Vector for dispatch:

f(v::AbstractVector) = sum(v)

Perhaps Part and PartView could similarly both be made to subtype AbstractPart. I know nothing about macros though, so no idea how to accomplish this.

1 Like