# Best coding of homogeneous types

**URL:** <https://discourse.julialang.org/t/best-coding-of-homogeneous-types/49939>\
**Category:** New to Julia\
**Created:** [November 10, 2020, 7:29pm UTC](https://discourse.julialang.org/t/best-coding-of-homogeneous-types/49939 "2020-11-10T19:29:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mocalvao](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mocalvao/32/19318_2.png) [@mocalvao](https://discourse.julialang.org/u/mocalvao)\
**Post date:** [November 10, 2020, 7:29pm UTC](https://discourse.julialang.org/t/best-coding-of-homogeneous-types/49939/1 "2020-11-10T19:29:27Z")

</div>

Hi,

I have a code where there are several Float64 type variables, which I would like to group as:

Group1: H\_0, Omega\_m0, Omega\_Lambda0  
Group2: Omega\_geom0, A, z\_f, z\_t

These groups, Group1 and Group2, will be used as arguments to certain functions and I would like to call their variables by the above names (H\_0, …, Omega\_geom0, …), not (only) by their indices. Thus I would like some suggestions as to which intrinsic Julia types to use, for better performance and convenience: named array (is there such a thing?), named tuple, dictionary, struct or whatever?

Thanks in advance

---

<div class="post-metadata">

**Author:** ![Vasily\_Pisarev](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/vasily_pisarev/32/7929_2.png) [@Vasily\_Pisarev](https://discourse.julialang.org/u/Vasily_Pisarev)\
**Post date:** [November 10, 2020, 9:22pm UTC](https://discourse.julialang.org/t/best-coding-of-homogeneous-types/49939/2 "2020-11-10T21:22:38Z")

</div>

I’d suggest named args for the functions, named tuples to group the values and splatting to pass the arguments:

```julia
group1 = (H_0 = H_0, Omega_m0 = Omega_m0, Omega_Lambda0 = Omega_Lambda0)

function myfunc(x, t; H_0, Omega_m0, Omega_Lambda0)
    # body
end

myfunc(x, t; group1...)

```

Also, IIRC, in 1.5

```julia
myfunc(x, t; H_0, Omega_m0, Omega_Lambda0)
# ^ note the semicolon

```

is the same as

```julia
myfunc(x, t, H_0=H_0, Omega_m0=Omega_m0, Omega_Lambda0=Omega_Lambda0)

```

So, you may choose to just have the appropriate variable names in the call scope without much need to group them into a structure.

---

<div class="post-metadata">

**Author:** ![rdeits](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rdeits/32/286_2.png) [@rdeits](https://discourse.julialang.org/u/rdeits)\
**Post date:** [November 10, 2020, 9:24pm UTC](https://discourse.julialang.org/t/best-coding-of-homogeneous-types/49939/3 "2020-11-10T21:24:32Z")

</div>

I would definitely recommend a `struct` or `mutable struct`, which you can learn more about here: [Types · The Julia Language](https://docs.julialang.org/en/v1/manual/types/#Composite-Types)

A named tuple will also work, but a `struct` gives you the opportunity to _name_ that collection of data in some meaningful way, and it makes it easy to create functions that operate on that particular collection of data.
