Andrei Alexandrescu:
> D doesn't look half bad:
> http://stackoverflow.com/questions/3538156/file-i-o-in-every-programming-language-closed

Yes, it looks nice, File looks well designed, its design is almost equal to the 
Python one (despite in that page they have used a different code strategy in 
Python).

I guess this line:
f.readln;
Will need to be written:
f.readln();


Regarding this:

auto f = File("fileio.txt", "w");
...
f.open("fileio.txt", "r");

It is correct, because it first calls detach(), but what is the purpose of the 
open() method? At first sight this is the main difference between the D and 
Python file API. Isn't it more clear and simpler to write just:

auto f = File("fileio.txt", "w");
...
f = File("fileio.txt", "r");

I don't see the need of the open() method, it looks like noise in the File API. 
Do you know its purpose?

Bye,
bearophile

Reply via email to