To do this kind of weird dynamic variable trixing in Julia, you have to use macros and metaprogramming. The gist of it is a very powerful interface to code generation. I think it would be possible to write a macro that does the same as the above code on the form
x1, x2, x3, x4 = 14, 12, 34, 19
@assign("abcd", 1:4)
and translates that "compile time" to
x1, x2, x3, x4 = 14, 12, 34, 19
begin
a = x1
b = x2
c = x3
d = x4
end
It will take me some time to write and debug such a macro. Can you describe your use case, so I can see if there are some constraints that are actually not important, or more functionality you'd like? The 1:4
for example seems redundant as I can just use for (i, letter) in enumerate("abcd")
to get the same loop.