Implementing typestate

Freddy via Digitalmars-d digitalmars-d at puremagic.com
Tue Sep 15 10:59:17 PDT 2015


On Tuesday, 15 September 2015 at 17:57:10 UTC, BBasile wrote:
>
> This won't work in D. Everything that's static is common to 
> each instance.
> What's possible however is to use an immutable FState that's 
> set in the ctor.
>
> ---
> struct File
> {
>     immutable FState state,
>     this(string fname, FState st){state = st}
> }
> ---
>
> Than you're sure that your file state can't be changed by error.
> Otherwise just hide the state to set it as a private variable...

No, I'm talking about adding a new feature to the language, 
modifable enums(typestate).


More information about the Digitalmars-d mailing list