On 8 August 2013 23:12, Jonathan S. Shapiro <[email protected]> wrote: > Now for the first sleeping dragon. > > What is the difference, if any, between: > > union rolist 'a is > readonly cons { car: 'a; cdr: rolist 'a } > nil; > > def rl : rolist 'a; > > > and > > union list 'a is > cons { car: 'a; cdr: list 'a; } > nil > > def rl : readonly list 'a; > > > That is: how are the two definitions of /rl/ different, behaviorally? > > Hint: it has nothing to do with nil, since lacking any fields nil is > inherently readonly.
In the first case the list head is mutable but it's fields are not so while we cannot alter the list through rl.cdr we can assign a different list head to rl, destroying the old list head and leaving a dangling list. In the second case the readonly annotation applies only to the list head since it is not transitive. While we cannot assign a new list head to rl as we can in the first case we are able to alter any part of the list after the list head. _______________________________________________ bitc-dev mailing list [email protected] http://www.coyotos.org/mailman/listinfo/bitc-dev
