std.socket classes

David Nadlinger via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Apr 10 14:27:08 PDT 2017


On Sunday, 9 April 2017 at 14:47:39 UTC, Jonathan Marler wrote:
> My guess is that making Socket a class prevents socket handle 
> leaks because you can clean up the handle in the destructor 
> when the memory gets freed if no one closes it.  Is this the 
> reason it is a class and are there any other reasons?

Just to definitively answer the question: The design has been 
done way before even D 1.0 – actually, 0.86, I just checked the 
Git history – and has stayed more or less unchanged since. 
Several people, including me, have patched up various issues 
since, but the clunky design stayed unchanged. Including it in D2 
proper was of course a mistake – it certainly wouldn't even come 
close to making it into Phobos today.

  — David


More information about the Digitalmars-d-learn mailing list