remyzorg/pendulum

`some_planets` example is not working

Closed this issue · 2 comments

There might be a problem in signals emission / reception.

Actually the programm wasn't correctly written.

But there is an other problem :
I add the syntax let .. = .. in for local signals and an other problem appears.

let%to_dot_grc mouse_machine =
  input ctx;
  input move;
  input quit1;
  input quit2;

  let circle  = ({x = fst (!!move); y = 50.; radius = 20.; color = "green"}) in
  trap ex1 (
    loop (
      present quit1 (exit ex1);
      present move (
        atom (
          move_circle !!ctx !!circle (fst !!move) !!circle.y
        );
        emit circle {!!circle with x = fst !!move; y = !!circle.y}
      ); pause)
  );
  atom (erase_circle !!ctx !!circle)
  ||
  let circle = ({x = 50.; y = snd (!!move); radius = 20.; color = "red"}) in
  begin
    trap ex2 (
      loop (
        present quit2 (exit ex2);
        present move (
          atom (
            move_circle !!ctx !!circle !!circle.x (snd !!move)
          );
          emit circle {!!circle with x = !!circle.x; y = snd !!move}
        ); pause));
    atom (erase_circle !!ctx !!circle)
  end

The generated is ill-typed as one if-branch returns Pause while one of the other returns unit

The return value must be removed from the tree and just add the state 0 to true (or not) and set signals to absent.
A test can be added at the end to return Present or Absent if needed