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.

Reply via email to