`restricted` member variables
forkit
forkit at gmail.com
Thu Jun 23 00:54:19 UTC 2022
On Thursday, 23 June 2022 at 00:48:13 UTC, Paul Backus wrote:
>
> ..
I disgree. It will mean D can finally be taken seriously.
With private(this), you are not longer constrained to defining a
type using the D module mechanism.
You can now actually create 'real' user-defined types.
As we already now, in D, a type created using the modular
mechanism, gets even less suppport than an int type.
By that I mean, I use can use an int type throughout my module,
and it's invariants will hold. The compiler will make sure of
this.
The same is not true for user-defined types, because they are
enabled using the D module mechansim.
That is, they do not own their type, so they cannot declare let
alone enforce invariants, since module owns them.
Thus any invariants of the user type cannot only be declared and
enforced by the module, and not the type.
Such types are not user-defined types.
With private(this), D turns into a language that supports
user-defined types.
That's a big deal, IMO.
More information about the Digitalmars-d
mailing list