Converting well structure VBA code, with multiple sub-routine call, to Julia

I have been using Julia for about a week using Vscode as my IDE. Simple examples not problems. My task at hand it to convert well structure code (in VBA) to Julia - I am solving a system of 130 ODE’s (initial value problem) with the solution taking way too long in VBA. My VBA code uses 100’s of global parameters (Private a, b, c … as Single (or Double or String or Integer) that are used in multiple subroutines in the VBA. Very convenient method for sharing parameters and keeping code tightly contained in sub-routine structures without the need to pass great long strings of arguments. I am lost as how to do this in Julia - I haven’t been able to find anything on structuring Julia programs. Can anyone help? Peter

Don’t use globals, they say… I’d wrap the parameters in a struct (or named tuple), you can then pass that as a single parameter to the functions. There are a bunch of helpers around to make things a bit easier. Have a look at Base.@kwdef,, and/or

1 Like

Received wisdom is that global state is “evil” (googling it will give many entries). You mention it’s a well structured VBA code, but where’s the structure if there are hundreds of global parameters?

You probably want to define your own data structures, which is quite straightforward.

So instead of many arguments:

function f(a, b, c)
    return a + b + c

You can group it in a struct (or e.g. a namedtuple):

struct MyData

function f(data)
    return data.a + data.b + data.c

The documentation can be found here:


Many thanks – that looks really interesting. I will investigate further. Yes, I was scared off by using Global

Thank you. I will take a look. Regards Peter Brisbane Australia