Typestates ========== Simple typestates ----------------- (Copied from syntaxtest.txt) type Lock = struct { ... } # only one type state in a typestate group can be active at a time. typestate Lock { noforget Locked, Available } # it is still a void return type func var threaded Lock.lock() [[Available]] -> [[Locked]] func var threaded Lock.release() [[Locked]] -> [[Available]] Or maybe this syntax: type Lock = struct { ... } # only one type state in a typestate group can be active at a time. typestate Lock { noforget Locked, Available } func var threaded Lock.lock() from Available to Locked func var threaded Lock.release() from Locked to Available "Coupled-object" typestates --------------------------- E.g. for allocations, if de-allocation has to be done with the same allocator as allocation. Typestate-preserving functions ------------------------------ typestate string { ValidUtf8 } func arena string.reverse() -> string ?[[ValidUtf8]] -> [[ValidUtf8]] func arena string.reverse() -> string preserves ValidUtf8