-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Closed
Labels
docsThis change adds or pertains to documentationThis change adds or pertains to documentation
Description
the docstring:
constis used to declare global variables whose values will not change. In almost all code (and particularly performance sensitive code) global variables should be declared constant in this way.
it may seem a bit too-obvious but I think the docs should emphasize more strongly here that a variable should only be declared const if it is actually constant. the wording "almost all code" is quite strong here and there might also want to be information here that it is not just about the value changing but about the non-reassignment
that is, I doubt this is a legal use of const even though the value never changes (...unless it is in fact legal?)
const x = 1
function foo()
while rand() < 0.99
global x = (rand(1:2:11)^2) % 4
println(x)
end
end
Metadata
Metadata
Assignees
Labels
docsThis change adds or pertains to documentationThis change adds or pertains to documentation