Java : Smalltalk風の制御構文

abstract class Cntr {
  abstract boolean cond();
  void ifTrue() {}
  void ifFalse() {}
  void once() {
    if (cond()) { ifTrue();}
    else        { ifFalse();}
  }
  void repeat() {
    while (cond()) { ifTrue();}
  }
  void until() {
    while (!cond()) { ifFalse();}
  }
}

public class Main {
  public static void main(final String[] args) {
    new Cntr() {
        boolean cond() { return args.length > 0;}
        void ifTrue()  { System.out.println(args.length + " arg");}
        void ifFalse() { System.out.println("no arg");}
      }.once();

    new Cntr() {
        int n = 0;
        boolean cond() { return 10 > n++;}
        void ifTrue()  { System.out.println("repeating... " + n);}
      }.repeat();
  }
}