[OT] Programming language WATs

Jonathan M Davis jmdavisProg at gmx.com
Mon Feb 6 17:18:14 PST 2012


On Monday, February 06, 2012 17:13:28 H. S. Teoh wrote:
> OK, so this thread was supposed to be about WATs in D. Today I found
> one.
> 
> 	std.stdio.File != std.stream.File
> 
> which means you can't assign stdin to InputStream.
> 
> Yes I know, you need to import cstream and use cstream.din instead, but
> this is very counterintuitive to a newcomer. It certainly elicited a WAT
> from me today when I first ran into this schizophrenic split between
> std.stdio (which is pretty much used in every D code example I've seen,
> which gives the impression that it's the "native" and "default" thing to
> use) and std.stream (which one would expect should naturally extend the
> functionality of std.stdio, but it doesn't).

I guess that it depends on how you think or what you're used to. I wouldn't 
necessarily expect std.stream to be related to std.stdio at all. Certainly. in 
C++, stream-based and non-stream-based I/O isn't related at all (or if it is, 
it's an implementation detail). So, my general expectation is that they're 
completely separate, though I suppose that they don't _have_ to be designed 
that way.

Given that std.stream has its own File type, that would make it pretty obvious 
that the File from std.stdio would not work with std.stream. But I guess that 
you could see a function taking File in std.stream without having read enough 
of std.stream's documentation to realize that it had its own File type.

- Jonathan M Davis


More information about the Digitalmars-d mailing list