I don’t know the issue well enough to be able to come up with an apt title to this thread.
My question is, what are the common, hand-editable data formats to initialize variables?
Suppose you want to supply various parameters and values to your Julia program from a hand-editable text file. What format would you use?
When I was using Fortran, the namelist was the obvious and most convenient format, because you can specify the names of the variables and their values in the text file. Instead of showing the exact format of Fortran’s namelist, I show a pseudo code:
# namelistfile.txt
arr = 1,3,5,9
s = "hellow world"
c = 3.0 + 2im
# pseudo Fortran code
integer:: a[4]
string:: s
complex:: c
namelist/myparameters/ arr, s, c
filehandle = open("namelistfile.txt")
read(filehandle, namelist=myparameters) # -> arr, s, and c are initialized
What do julia programmers use in such a case as this? You don’t want to invent an ad-hoc data format and write an ad-hoc parser. Perhaps you use JSON?
In my particular applications, I need to be able to express repetition:
a = 1, 2, 5*3, 4
instead of
a = 1,2,3,3,3,3,3,4
If there is no such a convenient format, I would perhaps just write a julia module that contains the const
ants and use it as if it were a datafile and load it via:
include(ARGS[1])
using .Parameters
A downside of this approach (shared by Fortran’s namelist) is that it’s very hard to use the datafile from other languages. If that’s important enough, perhaps I should use some common format like JSON. . . .