eliminate writeln et comp?
Georg Wrede
georg.wrede at iki.fi
Tue Mar 17 11:29:18 PDT 2009
Andrei Alexandrescu wrote:
> 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?
1. It is not often that a program that is first designed to write to
stdout is changed to write to somewhere else. (The whole reason of
stdout is, after all, that you can redirect outside the program!)
2. Of course it would be Proper (as in Prudent, almost as in goody
two-shoes) to write stdout.writeln. But then, to be useful the
programmer should write myOutDestination.writeln in order to be able to
"conveniently" later change the destination.
3. IMHO later redefining stdout would be a moronic idea. (And
/definitely/ not Prudent!)
4. Globals, shmobals... globals in spirit vs. globals in techicality. I
can't /believe/ there's any idea in totally banning globals. Heck, this
language has *goto*. Blind purism has made a few other languages
impractical.
5. Good defaults a good UI make. Can't we just decide that a bare
writeln(...) is defined as writing to stdout, period? Without thinking
of globals.
6. stdout is "global" to such an extent, that it actually exists outside
of the program. (RTF *nix man, man!)
Blehhhhhhh....
PS, I don't think you were serious with the post.
More information about the Digitalmars-d
mailing list