[phobos] std.stdio : ByChunk for File
Steve Schveighoffer
schveiguy at yahoo.com
Fri Aug 27 06:36:31 PDT 2010
I don't really understand the concern for adding another type... We add types
all the time for less important reasons.
What a separate type does is move the error from runtime to compile-time. When
spawning a process, it's going to be annoying if some times trying to start a
process throws a runtime error for a possibly trivial problem. With a compiler
error, the user is made aware of what is going to happen. If we go with the
runtime route, I'd elect to just ignore the fact that the buffer is not passed,
and have some sort of guideline in spawn's docs ("if you open a file with the
intent of passing it to spawn, make sure you open it with no buffer!").
-Steve
----- Original Message ----
> From: Lars Tandle Kyllingstad <lars at kyllingen.net>
> To: Phobos mailing list <phobos at puremagic.com>
> Sent: Fri, August 27, 2010 2:16:09 AM
> Subject: Re: [phobos] std.stdio : ByChunk for File
>
> I've been thinking some more about this, and I think you're right.
> Creating an entirely new type for this one use case may be overkill. A
> buffering-on/-off flag in File should suffice.
>
> Another point worth noting is that we only need the input stream to not
> be buffered. For the output and error streams, spawnProcess() would
> just call flush() before passing them on to the child process.
>
> Steven, do you have any comments?
>
> -Lars
>
>
> On Thu, 2010-08-26 at 22:14 -0700, Andrei Alexandrescu wrote:
> > Regarding UnbufferedFile, I think we should sit down and analyze again
> > what we want to achieve. I understand it's not easy to remember the
> > buffering mode for a file once opened, but since File intercepts fopen()
> > and setvbuf(), it should be easy to add a field to File that tells
> > whether it uses buffering or not, and to set buffering upon opening the
> > file. I don't think an entire new type is justified here.
> >
> > Andrei
> >
> > On 5/30/10 3:05 PDT, Lars Tandle Kyllingstad wrote:
> > > I agree. That's what I did for UnbufferedFile, which I hope to add to
> > > std.stdio:
> > >
> > > http://github.com/kyllingstad/ltk/blob/master/ltk/stdio.d
> > >
> > > -Lars
> > >
> > > _______________________________________________
> > > phobos mailing list
> > > phobos at puremagic.com
> > > http://lists.puremagic.com/mailman/listinfo/phobos
>
>
> _______________________________________________
> phobos mailing list
> phobos at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/phobos
>
More information about the phobos
mailing list