Implementing typestate
Ola Fosheim Grøstad via Digitalmars-d
digitalmars-d at puremagic.com
Wed Sep 16 07:34:03 PDT 2015
On Wednesday, 16 September 2015 at 10:31:58 UTC, Idan Arye wrote:
> What's wrong with two `open()`s in a row? Each will return a
> new file handle.
Yes, but if you do it by mistake then you don't get the compiler
to check that you call close() on both. I should have written
"what if you forget close()". Will the compiler then complain at
compile time?
You can't make that happen with just move semantics, you need
linear typing so that every resource created are consumed exactly
once.
More information about the Digitalmars-d
mailing list