Jonathan S. Shapiro wrote:
> On Wed, 2008-08-20 at 17:24 -0400, Swaroop Sridhar wrote:
>> In the case of defunion, should the union itself be mutable only if all
>> shallow fields in all legs are mutable?
> 
> Yes. This must be the case, because we cannot know which leg we will be
> handed. However, we exclude the tag value for this purpose, since that
> field isn't really visible in any case.
> 
>> The present rule (which says that the union is mutable if all
>> constructors only have mutable fields) might not be too bad in practice.
>> But, it seems unintuitive since it creates an artificial relation
>> between the mutually exclusive constructor legs.
> 
> I tend to agree, but I can't generate any other sensible
> interpretation...

Here is an interpretation which is possibly consistent:

(1) In the case of structures, the mutating of the entire structure is
equivalent to mutating all of the individual fields. Therefore, its
mutability is dependent on (rather is defined by) the mutability of its
constituent fields.

(2) In the case of unions, the mutating the union corresponds to
mutating the tag, which is independent of the mutability of any of its
constructor-fields. The locations holding the various constructions of
the union are permitted to change type (and therefore mutability) when
the tag changes.

Swaroop.

_______________________________________________
bitc-dev mailing list
[email protected]
http://www.coyotos.org/mailman/listinfo/bitc-dev

Reply via email to