Symbol Tables
- Binary Tree
- Binary Tree with Red-Black autobalancing algorithm
- Hash Table
- Linked List of name, value, and type sets
A Hash Table would have to have a bucket size large enough that there would not be any hash collisions, if not, the worst-case scenario is O(n) time. This is unacceptable if many variables and functions are present.
A Linked List would be a very poor choice, because a linked list's average lookup time is O(n). It would work for a small table, but not for many variables and functions.
Scala-ifying legacy code
This is the process of converting legacy Java code to Scala to take advantage of Scala features like traits and implicit type conversions. I have a significant amount of legacy code developed in a programming class in Java that I am reusing for this project, but I would like to be able to take advantage of Scala's features. Short of a full rewrite (which will happen eventually), I am starting with something like the following:
(Java) public class ExpressionTree implements ExpressionNode
{
...
public ExpressionNode getRoot()
{
return root;
}
...
}
(Scala) class SExpressionTree(tree:ExpressionTree)
{
def root() = tree.getRoot()
}
implicit def exprTree2ScalaExprTree(tree:ExpressionTree) = new SExpressionTree(tree)
This will enable the ExpressionTrees to be used as if they were native Scala objects. This is a stopgap measure until the whole library is ported to Scala, and then the symbol table will be implemented.
No comments:
Post a Comment