Phobos vs Tango! What's your opinion?

torhu fake at address.dude
Wed Apr 18 10:49:54 PDT 2007


Deewiant wrote:
> Alexander Panek wrote:
>> Deewiant wrote:
>>> [...] I don't quite agree with this, but I do prefer free functions in
>>> many cases. I
>>> can accept having a File class for "heavy-duty" file handling, but I
>>> still find
>>> myself missing a simple function for just dumping an ubyte[] array of
>>> a file's
>>> contents.
>> 
>> http://dsource.org/projects/tango/docs/current/tango.io.File.html
>> 
>> auto contentOfAFile = (new File( "filename" )).read;
>> 
>> There you go.
> 
> Of course. But I feel uneasy with throwaway objects, like I'm fighting the
> library. There's probably no good reason to, but I do.
> 

The only state contained in File is a FilePath instance.  Which means
you can do things like this:

auto f = new File("name");

if (f.path.exists)
      auto x = f.read();
else
      printf("file not found!\n");

But since you would probably wrap the whole thing in a try-catch block 
anyway, I'm not sure I'd ever do it like that.  On the other hand, you 
could also create the file, delete it, get its size etc.

So File basically combines FilePath and FileConduit into a single class, 
that's pretty easy to use.  But since the FileConduit part is the most 
useful aspect of File, I'd also be more than happy if Tango just 
provided free functions to read, write, append etc.

All in all, I haven't used Tango enough myself to really have an 
informed opinion about this issue.  Other people might, though.



More information about the Digitalmars-d mailing list