Implementing typestate

Ola Fosheim Grøstad via Digitalmars-d digitalmars-d at puremagic.com
Tue Sep 15 11:30:32 PDT 2015


On Tuesday, 15 September 2015 at 18:25:51 UTC, BBasile wrote:
> On Tuesday, 15 September 2015 at 18:15:46 UTC, Freddy wrote:
>> On Tuesday, 15 September 2015 at 18:10:06 UTC, BBasile wrote:
>>> 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 ?
>>
>> A simplified version of this: 
>> https://en.wikipedia.org/wiki/Typestate_analysis
>> Where types can have compile time state(enum) that change as 
>> they are used.
>
> Ok, I see. So type states can be used in static analysis to 
> find possible bugs if certain states-pattern are not found. In 
> the file example if after FState.open, fState.close is never 
> found then a compiler could emitt a warn about a possible leak 
> or something...wow that's pretty edgy...

It is the same type of concept. Typestate, effect system, linear 
typing, behavioural typing. It is no doubt the future for type 
systems, but also demanding. I've tried to raise awareness about 
it before, but no takers:

http://forum.dlang.org/post/ovoarcbexpvrrceysnrs@forum.dlang.org



More information about the Digitalmars-d mailing list