# Julep: Efficient Hierarchical Mutable Data

**URL:** <https://discourse.julialang.org/t/julep-efficient-hierarchical-mutable-data/125190>\
**Category:** Internals & Design\
**Tags:** mutable-structure, rfc\
**Created:** [January 25, 2025, 6:51am UTC](https://discourse.julialang.org/t/julep-efficient-hierarchical-mutable-data/125190 "2025-01-25T06:51:04Z")\
**Posts on this page:** 1\
**Showing post:** 35

<div class="post-metadata">

**Author:** ![JonasWickman](https://avatars.discourse-cdn.com/v4/letter/j/9de0a6/32.png) [@JonasWickman](https://discourse.julialang.org/u/JonasWickman)\
**Post date:** [January 30, 2025, 2:48pm UTC](https://discourse.julialang.org/t/julep-efficient-hierarchical-mutable-data/125190/35 "2025-01-30T14:48:51Z")

</div>

> [@PatrickHaecker](#):
>
> - returns wrong type for substructs: `w.part |> typeof`  
> `julia> w.part`  
> `PartView{:part, Whole}(Whole(42, 42.0f0))`
> - therefore, no methods involving `Part` can be called:  
> `inc(p::Part) = p.a += 1`  
> `julia> w.part |> inc`  
> ERROR: MethodError: no method matching inc(::PartView{:part, Whole})`

This seems very similar to how views work on vectors:

```julia-auto
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:

```julia-auto
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.

---

_[View the full topic](https://discourse.julialang.org/t/julep-efficient-hierarchical-mutable-data/125190)._
