I should amend this because I understand you're worrying about the alleged mutability of S in this example, and I suppose it depends on how you collect the properties: if taking a ref to Container.s returns a "ref S", where S looks immutable, this is clearly not correct.
There are two possibilities here: 1. You forbid taking a ref to a mutable field, unless the structure it points to is also mutable (mutable to only one level is probably sufficient). 2. Taking a ref to a mutable field returns a "ref mutable S", ie. you collect *all* the properties along the path when constructing a ref. This is the only maximally flexible option that I can think of. Sandro On 24/03/2011 10:14 AM, Sandro Magi wrote: > On 23/03/2011 5:56 PM, Jonathan S. Shapiro wrote: >> Among other consequences, this means that in a language having init-only >> fields and inner-references, a structure consisting exclusively of >> init-only fields is not necessarily pure... > > I'm not sure the example implies this conclusion. 'Container' clearly is > not init-only. Is it really surprising that introducing mutability > anywhere in a path means the purity of our immutable structures changes? > > Use of mutability, inner refs, etc. merely need to be possible and > sound. The example you provided is a hazard of working with any sort of > mutability, and I wouldn't fret over it. > > Sandro > > _______________________________________________ > bitc-dev mailing list > [email protected] > http://www.coyotos.org/mailman/listinfo/bitc-dev _______________________________________________ bitc-dev mailing list [email protected] http://www.coyotos.org/mailman/listinfo/bitc-dev
