why std.stdio.File is a struct?

Kagamin via Digitalmars-d digitalmars-d at puremagic.com
Thu Oct 20 02:53:53 PDT 2016


On Thursday, 20 October 2016 at 07:40:05 UTC, Jonathan M Davis 
wrote:
> User-defined types that manage system resources are pretty much 
> always better off as structs so that they can have 
> deterministic destruction.

They could be reference counted classes if it played well with 
the language.

> In general, in D, if you don't need inheritance and 
> polymorphism, you probably shouldn't be using a class.

Streams genuinely need polymorphism though because they can 
present a wide variety of devices.


More information about the Digitalmars-d mailing list