9fans archive / 2007 / 04 / 526 / prev next From: "Russ Cox" <rsc@swt...> Subject: Re: [9fans] scopes in kencc Date: Thu, 26 Apr 2007 23:02:39 -0400 > In my compilers class, the professor suggested using some linked list > of scopes so that lookup would always return the nearest symbol by a > given name (modulo namespace issues). Since there's a single global > symbol table in kencc, what tells lookup to return the properly scoped > symbol? only the properly scoped symbol is in the hash table during the lookup. new declarations replace old ones but the old ones get added to an undo log. when a } is reached, the undo log is applied to put the old ones back. this is a very common "implicit" representation of the scope. appel's book, at least, discusses it as an alternative to the linked-list-of-scopes approach. look for push1 and revertdcl. russ