On 04/08/2010 03:14 PM, Adam D. Ruppe wrote:
On Thu, Apr 08, 2010 at 03:55:43PM -0400, Adam D. Ruppe wrote:
alias FileImpl!(FILE*) File;
Problem with this: outside functions can't just take a File and expect it to
work. It isn't a deal breaker, since these functions could be changed to simple
templates, but it doesn't seem ideal.
I was about to write that. We'd be forcing client code to be templated.
This is a hindrance that would need substantial benefit to justify it.
Files based on different implementations being different types seems like a good
idea, since fclose() won't work on a range (for example), so assigning them to
each other won't work.
Let's not forget that File isn't a range. Let's call it a "stream
handle" that can _offer_ a number of ranges with various capabilities
(byLine, byDchar, byWchar, byChar, byChunk). I envision how we could add
ranges such as byPacket (variable-length packets returned as they come
off the wire) and byWhateverAbstractionIsNeededByZip.
I guess it either has to be an interface and classes, or used as templates,
to make this idea work.
In order to ensure refcounting and timely closing, File needs to be an
object. It could use the pimpl idiom inside in conjunction with a class
hierarchy.
Andrei
_______________________________________________
phobos mailing list
[email protected]
http://lists.puremagic.com/mailman/listinfo/phobos