[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Translator
I'm building a rewriting system that takes a structure, looks at its
name, and calls a special rewriting function for it. The system has
to be blazingly fast. There will be about 1000 kinds of structures.
The question is how to rapidly associate a name with a rewriting function.
Three methods come immediately to mind:
1) Use a CASE on the names, to get to the functions;
2) Use the name as a key to a hash-table that stores the functions;
3) Use the name to build a function-name, using (intern (string-append )).
Then call the function using (apply func-name).
Which one do you think is fastest? Does CASE somehow use pointers, or
does it have to cycle through its indices while comparing them (giving
O(n/2) time)? How efficient are Symbolics hash-tables?
Does intern need to look up the name in a hash-table? How about apply?
Is there any good way to intercept the "function undefined" trap
when method (3) is used with a new named structure unknown to my system?
(The "structure" is not necessarily a LISP defstruct'ed object.)
--John Myers