# 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:** 24

<div class="post-metadata">

**Author:** ![foobar\_lv2](https://avatars.discourse-cdn.com/v4/letter/f/ee59a6/32.png) [@foobar\_lv2](https://discourse.julialang.org/u/foobar_lv2)\
**Post date:** [January 27, 2025, 3:01pm UTC](https://discourse.julialang.org/t/julep-efficient-hierarchical-mutable-data/125190/24 "2025-01-27T15:01:54Z")

</div>

> [@StefanKarpinski](#):
>
> The key question about this proposal to me (which I don’t see addressed, but may have missed), is what happens when a reference to `p` outlives any references to `w`?

My proposal above would look like

```julia
struct FieldRef{T}
owner::Any #for GC purposes only
ptr::Ptr{T}
end

```

and would rely on the hypothetical new `Core.Intrinsics.interior_pointerset(owner, ptr, value)` thing that writes `value` to `ptr`, while applying the GC write-barrier as if `value` had been written to a field of `owner`.

That would be relevant for

```julia
struct Inner
  x::Vector{Int}
end

mutable struct Owner
  part::Inner
end

reset!(ref::FieldRef{Inner}) = ref[] = Inner(Int[])

owner = Owner(Inner(Int[]))
reset!(getfieldref(owner, :inner)) #needs a GC barrier if owner is old-gen!

```

---

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