I often want to export some values (variables) from a module and am wondering how to delete intermediate variables. As an illustration:
module somemod
export var1, var2, . . .
a1 = . . . # intermediate variables
a2 = . . . #intermediate variables
# . . .
const var1 = . . . calculation over a1, a2, . . .
const var2 = . . . calculation over a1, a2, . . .
end
As you can see, the variables a1
, a2
, . . . can be discarded once the exported values have been calculated. What’s the standard/idiomatic way to discard these intermediate variables?
Of the top of my head, I think we can do something like this:
(var1, var2, . . . ) =
let
a1 = . . .
a2 = . . .
# . . .
var1 = . . .
var2 = . . .
# . . .
(var1, var2, . . .)
end
which is fine but looks too much contrived (unnatural) to me.