Unsupported `const` declaration on local variable in Julia

Viewed 822

In Julia, I have defined a function which takes some arguments x,y,z, each of them doesn't change in through the process inside the function. For optimizing my program , I intended to make x,y,z be const. I did it like this:

function myFunc(x,y,z)
  const x = x; const y = y; const z = z;
  
  # algorithm using x,y,z
  # ...
  # ...

end

However, I caught an error below:

syntax: unsupported `const` declaration on local variable around In[55]:36

What is wrong?

Any information would be appreciated.

1 Answers

It is currently not supported, and shouldn't be needed for performance reasons (although it could be useful for catching accidentally mutating arguments). See https://github.com/JuliaLang/julia/issues/5148 for some more discussion.

Related