# How to pass variables to several levels up without going through headings (arguments) in functions

**URL:** <https://discourse.julialang.org/t/how-to-pass-variables-to-several-levels-up-without-going-through-headings-arguments-in-functions/112582>\
**Category:** General Usage\
**Tags:** fortran, functions\
**Created:** [April 5, 2024, 6:35pm UTC](https://discourse.julialang.org/t/how-to-pass-variables-to-several-levels-up-without-going-through-headings-arguments-in-functions/112582 "2024-04-05T18:35:59Z")\
**Posts on this page:** 5\
**Page:** 2

<div class="post-metadata">

**Author:** ![fmontans](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fmontans/32/202948_2.png) [@fmontans](https://discourse.julialang.org/u/fmontans)\
**Post date:** [April 6, 2024, 1:02am UTC](https://discourse.julialang.org/t/how-to-pass-variables-to-several-levels-up-without-going-through-headings-arguments-in-functions/112582/21 "2024-04-06T01:02:59Z")

</div>

> [@goerz](#):
>
> I would even say that Julia and modern Fortran are so similar that I’ve been able to port large swaths of Fortran code by copying it to a `.jl` file and doing some very basic search-and-replace to adjust the syntax.

The same thinking as fortran is probably why I like so much Julia. Aside greek symbols, subindices and defining operator symbols. Extremely easy to read, hence to understand and maintain. And as a plus, getting rid of Matlab. All this is why I want to move my code to Julia (apart from engaging my much-younger students into it).

Again, thank you all a lot for all the support to the novice!

---

<div class="post-metadata">

**Author:** ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)\
**Post date:** [April 6, 2024, 6:31am UTC](https://discourse.julialang.org/t/how-to-pass-variables-to-several-levels-up-without-going-through-headings-arguments-in-functions/112582/22 "2024-04-06T06:31:50Z")

</div>

I’m not in the field and to be honest don’t even know what is is (fine elements? Aren’t they all? I’ve never met an infinite one!) but I thought I’d mention that there’s a well maintained library/ecosystem here

> **[GitHub - PetrKryslUCSD/FinEtools.jl: Finite Element tools in Julia](https://github.com/PetrKryslUCSD/FinEtools.jl)**
>
> Finite Element tools in Julia. Contribute to PetrKryslUCSD/FinEtools.jl development by creating an account on GitHub.

which might be of interest. (I’d tag Petr as well if the Discourse tagging thing would work on mobile!)

---

<div class="post-metadata">

**Author:** ![bertschi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bertschi/32/33462_2.png) [@bertschi](https://discourse.julialang.org/u/bertschi)\
**Post date:** [April 6, 2024, 10:03am UTC](https://discourse.julialang.org/t/how-to-pass-variables-to-several-levels-up-without-going-through-headings-arguments-in-functions/112582/23 "2024-04-06T10:03:53Z")

</div>

Reminds me of this Ed Post quote from '82:

> The determined Real Programmer can write FORTRAN programs in any language.

On the other hand, I probably just tend to write Common Lisp or Haskell in Julia 😉

```julia
const diam = splat((:))∘extrema

```

---

<div class="post-metadata">

**Author:** ![Eben60](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/eben60/32/13475_2.png) [@Eben60](https://discourse.julialang.org/u/Eben60)\
**Post date:** [April 6, 2024, 10:31am UTC](https://discourse.julialang.org/t/how-to-pass-variables-to-several-levels-up-without-going-through-headings-arguments-in-functions/112582/24 "2024-04-06T10:31:11Z")

</div>

> [@bertschi](#):
>
> Collect related parameters into a `struct` and just pass it as a single argument.

If the only purpose is just to pass a large number of arguments, I pack them into a NamedTuple. Which can be extended (by merging), mutated (by merging), unpacked by name or by position, or passed as kwargs.

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [April 6, 2024, 12:28pm UTC](https://discourse.julialang.org/t/how-to-pass-variables-to-several-levels-up-without-going-through-headings-arguments-in-functions/112582/25 "2024-04-06T12:28:46Z")

</div>

> [@nilshg](#):
>
> but I thought I’d mention that there’s a well maintained library/ecosystem here: FinEtools.jl

(There is also Gridap.jl and some other packages … I seem to remember a summary of Julia FEM packages somewhere, but I can’t find it at the moment.)

[Previous page](https://discourse.julialang.org/t/how-to-pass-variables-to-several-levels-up-without-going-through-headings-arguments-in-functions/112582.md?page=1)
