Skip to content

Commit 0d1d4ba

Browse files
authored
clarify tip about untyped globals: const globals need no annotation (JuliaLang#54379)
The performance tip from JuliaLang#43671 by @simeonschaub > If a global is known to always be of the same type, [the type should be annotated](https://docs.julialang.org/en/v1/manual/variables-and-scoping/#man-typed-globals). was a bit unclear to me, because it does not apply to `const` globals (whose type requires no annotation). This PR clarifies that point
1 parent 1221160 commit 0d1d4ba

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

doc/src/manual/performance-tips.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ performance:
2626
const DEFAULT_VAL = 0
2727
```
2828

29-
If a global is known to always be of the same type, [the type should be annotated](@ref man-typed-globals).
29+
If a non-constant global is known to always be of the same type, [the type should be annotated](@ref man-typed-globals); `const` globals need not be annotated because their type is inferred from their initialization value.
3030

3131
Uses of untyped globals can be optimized by annotating their types at the point of use:
3232

0 commit comments

Comments
 (0)