Implementing typestate
Ola Fosheim Grøstad via Digitalmars-d
digitalmars-d at puremagic.com
Wed Sep 16 10:23:01 PDT 2015
On Wednesday, 16 September 2015 at 17:15:55 UTC, Ola Fosheim
Grøstad wrote:
> dostuff(r);
>
> (File<Open> f, FileRef<Void> r) = f.unborrow(r);
Of course, files are tricky since they can change their state
themselves (like IO error). Doing that statically would require
some kind of branching mechanism with a try-catch that jumps to a
different location where the file type changes to "File<Error>"...
Sounds non-trivial to bolt onto an existing language.
More information about the Digitalmars-d
mailing list