static class Symbol { S text; MasterSymbol master; *() {} *(S *text, bool dummy) {} // weird signature to prevent accidental calling *(S *text, MasterSymbol *master) {} bool isMaster() { ret master == this; } public int hashCode() { ret main.hashCode(master.lowerCase); } toString { ret text; } public bool equals(O o) { if (!(o instanceof Symbol)) false; bool result = o instanceof Symbol && master == o/Symbol.master; ifdef symbol_debug print("Symbol.equals: " + this + " vs " + o + " => " + result); endifdef ret result; } } static class MasterSymbol extends Symbol { S lowerCase; *() {} *(S *text, bool dummy) { master = this; lowerCase = lower(text); } }