Eve icon indicating copy to clipboard operation
Eve copied to clipboard

Can't make circular structure in single commit clause

Open frankier opened this issue 8 years ago • 1 comments

See below for an example of a program trying to commit a circular structure that doesn't work currently. If you break the cycle by removing either of the two next attributes, it behaves as you'd expect.

Expected behaviour: Display "yes" and alternate between "yes" and "no" on click. Actual behaviour: Displays nothing.

commit
  yes = [#mode text: "yes" next: no]
  no = [#mode text: "no" next: yes]
  [#current-mode mode: yes]
search @session @event
  [#current-mode mode: [#mode text]]
bind @browser
  [#div text]
search @session @event
  [#click]
  current-mode = [#current-mode mode]
commit
  current-mode.mode := mode.next

frankier avatar Nov 12 '16 05:11 frankier

ok - the issue here is that 'yes' and 'no' are mutually referential . the easy fix in this case is to use the '|' syntax to distinguish between attributes which form the extensional identity of the new object, and those which are merely optional attributes.

so: commit yes = [#mode text: "yes" | next: no] no = [#mode text: "no" | next: yes]

allows you to do what you intended without adding another block.

the real issue (unless you disagree) is that Eve currently doesn't give you any feedback that it couldnt find a valid evaluation strategy and just gave up. That doesn't seem very helpful.

convolvatron avatar Nov 14 '16 22:11 convolvatron