sclass WaitForName { S question; persistently swappable S answer(S s) { if (isCancelCommand(s)) ret cancel(); S name = nameFromInput(s); if (name != null) { cancelSilently(); print("Processing name: " + quote(name)); ret processName(s); } ret otherInput(s); } persistently swappable S nameFromInput(S s) { ret s; } persistently swappable S otherInput(S s) { ret "I don't understand. " + question; } persistently swappable S processName(S name) { ret "You said: " + name; } persistently swappable bool isCancelCommand(S s) { ret match("cancel", s); } persistently swappable void cancelSilently() { print("Cancelling"); } persistently swappable S cancel() { cancelSilently(); ret "Action cancelled"; } }