/** * Mondo-Bizarro ported to Java. * Based on mondo-bizarro by Eugene Kohlbecker * ACM SIGPLAN Lisp Pointers, Volume 1, Issue 2 (June-July 1987) pp 22-28 */ /* Original Scheme code: (define mondo-bizarro (let ( (k (call/cc (lambda (c) c))) ) (write 1) (call/cc (lambda (c) (k c))) (write 2) (call/cc (lambda (c) (k c))) (write 3))) */ interface Continuation { public void run(Continuation c); } public class Mondo implements Continuation { public static void main(String argv[]) { Continuation c = new Mondo(); c.run(c); } public void run(Continuation c) { Continuation let = new Let(); let.run(c); } class Let implements Continuation { Continuation k; public void run(Continuation c) { k = c; System.out.println("1"); k.run(new C2()); } class C2 implements Continuation { public void run(Continuation c) { System.out.println("2"); k.run(new C3()); } } class C3 implements Continuation { public void run(Continuation c) { System.out.println("3"); } } } }