# NamedVecs.jl - Is this a good idea?

**URL:** <https://discourse.julialang.org/t/namedvecs-jl-is-this-a-good-idea/68275>\
**Category:** Modelling & Simulations\
**Created:** [September 16, 2021, 4:00pm UTC](https://discourse.julialang.org/t/namedvecs-jl-is-this-a-good-idea/68275 "2021-09-16T16:00:45Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Per](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/per/32/10387_2.png) [@Per](https://discourse.julialang.org/u/Per)\
**Post date:** [September 16, 2021, 4:00pm UTC](https://discourse.julialang.org/t/namedvecs-jl-is-this-a-good-idea/68275/1 "2021-09-16T16:00:45Z")

</div>

The Julia ecosystem is reaching a size where, if something seems like a good idea, there’s probably a package for it. And conversely, if there is no package, then there’s probably a reason why such a package is not a good idea. So I think I should ask before I end up wasting my time…

I’m writing a package that would let me combine a bunch of different-size arrays into a vector, so that this vector can be passed to general linear-algebra code. But at the same time, I can access those arrays like the fields of a NamedTuple. (Machine-learning packages do something like this, but as far as I know, there’s no way to get the collection of parameters as an `AbstractVector`.)

[https://github.com/perrutquist/NamedVecs.jl](https://github.com/perrutquist/NamedVecs.jl)  
(The example in the readme uses DifferentialEquations.jl, but I actually want to use it in some modelling/optimization code that I am developing separately. I want to get rid of a lot of boilerplate code that passes sizes around.)

I’ve got a proof-of concept working, but before I spend any more time on this, I thought I should ask if anybody knows about an existing package that already has this functionality?

Or is there some major drawback to this approach that I haven’t thought of?

---

<div class="post-metadata">

**Author:** ![tbeason](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tbeason/32/15898_2.png) [@tbeason](https://discourse.julialang.org/u/tbeason)\
**Post date:** [September 16, 2021, 4:19pm UTC](https://discourse.julialang.org/t/namedvecs-jl-is-this-a-good-idea/68275/2 "2021-09-16T16:19:26Z")

</div>

Have not looked in depth here but isn’t this what StructArrays.jl does?

[https://github.com/JuliaArrays/StructArrays.jl](https://github.com/JuliaArrays/StructArrays.jl)

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [September 16, 2021, 4:24pm UTC](https://discourse.julialang.org/t/namedvecs-jl-is-this-a-good-idea/68275/3 "2021-09-16T16:24:25Z")

</div>

[https://github.com/jonniedie/ComponentArrays.jl](https://github.com/jonniedie/ComponentArrays.jl)

I’d usually suggest this one.

---

<div class="post-metadata">

**Author:** ![Per](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/per/32/10387_2.png) [@Per](https://discourse.julialang.org/u/Per)\
**Post date:** [September 16, 2021, 4:27pm UTC](https://discourse.julialang.org/t/namedvecs-jl-is-this-a-good-idea/68275/4 "2021-09-16T16:27:26Z")

</div>

That seems to be exactly what I need. Thanks!

---

<div class="post-metadata">

**Author:** ![Per](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/per/32/10387_2.png) [@Per](https://discourse.julialang.org/u/Per)\
**Post date:** [September 16, 2021, 4:41pm UTC](https://discourse.julialang.org/t/namedvecs-jl-is-this-a-good-idea/68275/5 "2021-09-16T16:41:49Z")

</div>

StructArrays.jl seems to be for a slightly different use case, but also worth knowing about. Thanks.
