Global side effects
Direct global side effects
Global side effects aren't allowed in ordinary functions. (Though log is allowed.)
That means we still haven't done a proper "Hello, world"!
Any function that directly directly has a global side effect must be marked with the global spec.
Even observing global state, such as reading a file, is considered a global side effect.
Global side effects through a lambda
A function without the global spec can still call lambdas that have global side effects.
Notice that while a global side effect happened during do-times,
do-times itself does nto have global side effects.
So it does not have to be marked global.
Creating a lambda that does global things is global, but calling the lambda is not.
A data lambda can not have global side effects.
Global side effects through an interface
A similar thing can be done with interfaces.
Notice how my-printer had to be marked as global.
Marking a record as global makes its new
(and named my-printer) functions global as well,
so you can only construct a my-printer in global code.
If a record is global, it can implement an interface using global functions.
The interface needs to be mut for this to work, since data types can't have side effects.
Trusting global side effects
Global variables
The following defines a global variable:
A global variable can have an initializer. Otherwise it defaults to gc-safe-value .