News for hackers. Stuff that matters.
Re:It's not what programming languages do, it's what they sh... by clarry on Friday March 27, 2020 @09:48AM (#22702773)
> Another example are "near constants" like a locale setting, an environment variable that gets detected once at startup, or a development feature flag. The "proper" way to structure those is to create a settings object and pass it to every function that needs them, but judicious use of a well-documented global can prevent a lot of boiler plate code.

In small programs, globals are ok, but in larger programs a better approach would be a global accessor that gives you read-only access:

    printf("%s\n", Environment()->Host);
This doesn't require passing an object to every function, and the application still can't trample on these variables.

There are no comments on this comment yet.