# recurse.ludic — EV6: re-entrant emit is bounded. Ping's listener emits Pong, # Pong's listener emits Ping — an event cycle that would hang the frame forever. # The depth bound (EV_DEPTH_CAP) makes the nesting trap as an early return, so the # program terminates with a bounded count instead of spinning. This is the "no # runaway event cycle" guarantee. # # Running it prints: 16 (the cycle bottoms out at the depth cap, deterministically) program Recurse { var n: int = 0 event Ping { } event Pong { } @On(Ping) handler A { n += 1; emit Pong() } # each Ping deepens by one Pong @On(Pong) handler B { emit Ping() } # ...and each Pong by one Ping entry { emit Ping() print(n) } }