Implementing typestate

Tobias Müller via Digitalmars-d digitalmars-d at puremagic.com
Tue Sep 15 22:51:50 PDT 2015


Ola Fosheim Grøstad <ola.fosheim.grostad+dlang at gmail.com> wrote:
> On Tuesday, 15 September 2015 at 20:34:43 UTC, Tobias Müller wrote:
>>> There's a Blog post somewhere but I can't find it atm.
>> 
>> Ok found it: > http://pcwalton.github.io/blog/2012/12/26/typestate-is-dead/
> 
> But that is for runtime detection, not compile time?

Not as far as I understand it.
The marker is a type, not a value. And it's used as template param.
But you need non-copyable move-only types for it to work.

In D it would probably look like:

File!Open file = open(...);
File!Closed file = close(file);

Tobi


More information about the Digitalmars-d mailing list