phobos: What type to use instead of File when doing I/O on streams?
J.Frank via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Mon Nov 9 00:49:06 PST 2015
On Sunday, 8 November 2015 at 23:50:58 UTC, Adam D. Ruppe wrote:
> You don't, in general. stdin is sometimes seekable and the
> compiler doesn't know if it is or not until you try at runtime.
Hm. "Maybe the stream is seekable, maybe it is not" is not really
an option for a language that is supposed to be type safe.
I just found std.stream which looks very good. But it is
deprecated??
> You could write a wrapper struct for File though that @disables
> the seek function. It would have a File member, alias file
> this;, a constructor that forwards to it (optionally, you could
> also construct it as a File and assign it), and then a
> @disabled function with the same signature as the seek call in
> File. Then, it will no longer compile as long as you use your
> wrapper.
Thank you for your solution, but this sounds more lika a hack.
More information about the Digitalmars-d-learn
mailing list