== Quote from Andrei Alexandrescu ([email protected])'s article > Hey all y'all, > Here's another nice bicycle shed discussion. During the recent > discussion about globals being harmful, Walter told me something that > made me think. I said, hey, there are things that are global - look at > stdout. He said, well, that's a bad thing. He then argued that it would > be better and cleaner to write: > stdout.writeln("Hello, world"); > instead of the current: > writeln("Hello, world"); > On one hand, I agree with Walter. On the other, I want to avoid the > phenomenon of the all-too-long "Hello, world" example. > What do you think? > Andrei
To me, the current form is best because it doesn't force you to explicitly specify that you want to write to stdout. Thus, it makes simple things simple. Of course DWIM isn't always a good idea, but when an obvious, safe default exists, I prefer not to have to explicitly specify this kind of stuff unless I want to override the default. Also, I don't see globals as being all that evil in themselves. Global _mutable_ state is an absolute mortal sin, but I see absolutely nothing wrong with global variables that are immutable, or even set once and treated as read-only by convention after initialization.
