[bitc-dev] on mutable types
Jonathan S. Shapiro
shap at eros-os.org
Sat May 20 06:42:20 EDT 2006
On Sat, 2006-05-20 at 07:48 +0100, Sam Mason wrote:
> On Sat, May 20, 2006 at 01:26:05AM -0400, Swaroop Sridhar wrote:
> > No extra level of indirection is introduced. The mutable keyword
> > qualifies the type of an expression, allowing it to be mutated.
>
> OK, but in that case the spec sounds a little confused to me.
> In the section about make-vector it says, of a (vector uint32), that
> "The vector created ... will contain immutable copies of the value"
> (it actually misses the example code demonstrating it, but never mind).
This part is correct. The vector was declared as containing immutable
cells, which is why the copies are immutable.
> It then goes on to say, of a (vector (mutable uint32)), that it "creates
> a vector ... each cell of which contains a mutable pointer".
This is an error, and I have corrected it. Thank you! I suspect that
this text is very old, and predates our decision to move from SML-style
"ref" to the current "mutable".
> The thread titled "Type compatibility at application" seemed to confirm
> my suspicions about this issue, but I've reread it and I think I was
> just misinterpreting what the problem was.
The problem there is simply to explain why it is okay to pass (by copy)
a mutable value in an argument position expecting an immutable value.
Because of the way that alpha types bind, this can be a very confusing
issue.
> I guess that formalising the semantics would be helpful, but I'm not
> remotely experienced in doing this and tend to work in a much more
> ad-hoc manner. I'll try and think about it a bit more.
We're going to start work on that pretty soon.
shap
More information about the bitc-dev
mailing list