On Tuesday, 15 September 2015 at 17:59:19 UTC, Freddy wrote:
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).
Ok, sorry I didn't know this concept so far.
So there would be a kind of 'compile-time instance' of File with
a modifiable member ?