[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: cyclic

sean@plan9.bell-labs.com wrote:
> i don't understand.  the semantics of limbo allow exactly that,
> if you use the cyclic keyword appropriately in the adt definitions.
> do you have a specific example?
> sean

A simple circular list does not behave as expected when an element
of the list is modified (since ref "makes a new object and returns
a reference to it, rather than generating a reference to an existing
object", 4-26 b.2).

Foo: adt{
        link: cyclic ref Foo;
        i: int;

        foo := Foo(nil, 0);
        bar := Foo(nil, 1);
        foo.link = ref bar;
        bar.link = ref foo;
        # foo.i and bar.link.i are both 0
        foo.i = 3;
        # foo.i is now 3 and bar.link.i is still 0

The "circularity" of the data structure has been broken by dynamically
updating a member, and I find the semantics here unexpected.  I
suggested the keyword change for this reason.