Closed fub-frank closed 11 years ago
Instead of isDeclared and isDeclaredInCurrentScope you could write one function with the symbol table, which declared the identifier, as result, or null if there is none. This way, isDeclared can be used with a simple null check and isDeclaredInCurrentScope with an equality check to the current symbol table. And if you need you also get the right symbol table, in which the identifier is declared.
I think function names beginning with "is*" should always return boolean values by name convention. If above functionality is wished we can add a new function like
/**
* Returns the SymbolTable that declares the identifier.
* It checks this symbol table and all parents up to the root symbol table until the identifier is found.
* @param identifier The identifier to look for
* @return The SymbolTable that declares the identifier or null if the identifier is not declared
*/
public SymbolTable getDeclaringSymbolTable(String identifier);
This way, isDeclared can be used with a simple null check and isDeclaredInCurrentScope with an equality check
I am not a fan of mixing different functionalities into one function.
// update of Course isDeclared and isDeclaredInCurrentScope can then be implemented by using the getDeclaringSymbolTable method. But this would be quite inperformant, as a normal lookup in a hashmap is neraly O(1)
if no more comments are posted on this issue by 12a.m. tonight i will close it and update the interfaces as described above.
The SymbolTable interface needs to be extended. The following features have been requested:
Proposal