[rust-dev] I would like to remove typestate.
niko at alum.mit.edu
Fri Jul 13 09:04:28 PDT 2012
Per recent discussions, I would very much like to remove code related to
typestate. It seems that the current approach is not scaling up to real
problems. There has been some discussion about alternative,
lighterweight approaches. I am not opposed to such forward motion.
However, the current code is holding me back from landing an improvement
to region inference—and I have to choose now whether to refactor it or
remove it. Given that we expect the system to change significantly and
therefore that the current code will not be especially useful, I would
prefer to remove it.
In particular the problem centers around the checking and treatment of
function preconditions. These are not currently represented as
expressions but rather a special, more limited predicate form. They
don't have node ids. Type checking then synthesizes expressions and
creates node ids. The region code then gets confused because it relies
on node ids as names for scopes and other things, and these synthesized
node ids don't appear in the AST nor in the various tables based on the
AST (they are, after all, synthesized).
As I said, there are various ways to repair this situation, but given
that the code is on life support, I'd rather not expend energy fixing
it. My plan for removal would be to convert all remaining function
preconditions into assertions. Last time I discussed this on IRC,
Graydon objected I think because he was concerned that there were checks
that were being relied upon but which would not be lost. I am not sure
if converting existing checks into assertions assuages those concerns.
More information about the Rust-dev