Listing 7: Nested function version of Listing 6.
class Symbol { char[] id; Symbol left; Symbol right; } Symbol symbol_membersearch(Symbol[] table, char[] id) { Symbol sm; void membersearchx(Symbol s) { while (s) { if (id == s.id) { if (sm) error("ambiguous member %s\n", id); sm = s; } if (s.left) membersearchx(s.left); s = s.right; } } for (int i = 0; i < table.length; i++) { membersearchx(table[i]); } return sm; }