static class Symbol { S text; MasterSymbol master; *() {} *(S *text, bool dummy) {} // weird signature to prevent accidental calling bool isMaster() { ret master == this; } public int hashCode() { ret main.hashCode(master.lowerCaseText); } toString { ret master.text; } public bool equals(O o) { ret o instanceof Symbol && master == o/Symbol.master; } } static class MasterSymbol extends Symbol { S lowerCaseText; *() {} *(S *text, bool dummy) { lowerCase = lower(text); } }