D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 5002 - possible std.stream improvements
Summary: possible std.stream improvements
Status: RESOLVED WONTFIX
Alias: None
Product: D
Classification: Unclassified
Component: phobos (show other issues)
Version: D2
Hardware: All All
: P2 enhancement
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-10-06 09:21 UTC by Daniel Gibson
Modified: 2015-11-03 16:08 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Daniel Gibson 2010-10-06 09:21:40 UTC
I've got a few suggestions to make std.stream more convenient (and in one case just the documentation more clear). See my NG post [1] for details, I'll just summarize it here:

* The documentation claims write( <basic type> ) is implementation specific - this is not true for most types - it's actually platform specific and with the EndianStream most read/write operations can safely be used between different platforms. Especially for the SocketStream this is good to know.

* InputStream's read( <type> val ) sometimes is inconvenient, please add something like
T read(T)() { T ret; readExact(&ret, ret.sizeof); return ret; }
So one can use "myFun( s.read!float );" instead of "float x; s.read(x); myFun(x);"

* Minor inconsistencies: add readExact(ubyte[] buf) to Inputstream, because there is a read(ubyte[] buf) and add writeExact(ubyte[] buf) to OutputStream because there is write(ubyte[] buf).

* For convenience ubyte[] readExact(size_t len) might be nice.

Thanks,
- Daniel

[1] http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D&article_id=118413 - my NG post on these matters (and also on bug 5001)
Comment 1 nfxjfg 2010-10-06 20:54:14 UTC
I thought std.stream is deprecated.
Maybe "someone" could confirm and close this as invalid.
Comment 2 Daniel Gibson 2010-10-11 13:20:40 UTC
It will probably be deprecated, but at this time it isn't (there is no alternative yet, anyway).

However I just realized that my idea for read() can't be implemented *that* easy because it wouldn't work properly with EndianStream.
For that to work one would have to check whether T is a simple type (int, float, double, long, etc) and in that case call fixBO() in EndianStream (like the available, inconvenient read(<basic type>) methods in EndianStream already do).

Or do it old school and provide readInt(), readUInt(), readLong(), readUlong(), readFloat() etc instead of using a template.
Comment 3 Robert Schadek 2015-11-03 16:08:45 UTC
std.stream is deprecated and will be removed in 2016