On Wed, Mar 23, 2011 at 4:22 PM, Pal Engstad <[email protected]>wrote:
> I'm not clear on what exactly const and mutable means here... Sorry. That seems to be an inherent hazard when discussion mutability. > ..., but shouldn't that be two type errors? > I don't think so. I think it's one type error resulting from a typo. See below. > > struct S > is > const i : int32 > const next nullable S > > boxed struct Container > is > mutable s : S; > > def S_length(s : S) > in > case tmp = s in > null => 0:int32 > otherwise => 1 + S_length(s.next); > > def f() > in > let container = Container(S(5, null)) > chain = S(4, container.s) > ~~~~~~~ > Type Error: container.s is mutable, but argument > 2 in the constructor is const. > Nope. The const-ness of the passed argument doesn't matter, because this is a copy boundary. The actual parameter here ans the formal parameter are copy compatible. > > len = S_length(chain) > in > container.s.next = S(6,S(7,null)) > ~~~~~~~~~~~~~~~~~~~~ > Type Error: Trying to mutate a const struct member. > This is the typo. The line should read "container.s" rather than "container.s.next". My apologies! shap
_______________________________________________ bitc-dev mailing list [email protected] http://www.coyotos.org/mailman/listinfo/bitc-dev
