On Tue, 3 Aug 2004, Stephen Andrew Neuendorffer wrote: [about making names of internal functions like 'map' or 'sin' evaluate to something.]
> Unfortunately, implementing this in practice is a little hard, since the > map() function is discovered through Java's reflection mechanism which > searches for methods with particular arguments... The 'right' thing to > do is to find all of the functions with the name 'map' with the correct > number of arguments, and return a function closure that invokes the > right Java function based on the type of the arguments. > If we wanted to get really fancy, then we could process all of the > methods at startup and build big lookup tables for every set of function > arguments and every function name, what is the right java method to > invoke. Note that Java and C++ do not do this, since the tables can > grow large when you are performing method selection based on all the > arguments. Are there any obstacles to doing it the first way, avoiding compiling huge tables? When a name is not found in the symbol table, the system could use reflection to see if the name resolves to anything that way. I.e. if 'map' isn't found in the symbol table, then the reflection mechanism would search (in UtilityFunctions, I guess) for functions named 'map' with any return type and any argument type. I suppose one problem is what to do in the case of overloading -- if there are multiple functions with the same name but different argument types. Are there any overloaded functions accessible from the expression language already? The functions to extract a subarray are a tempting area for overloading. It seems sort of silly to create distinctly named functions for the (int), (int, int), ({boolean}), and ({int}) argument types, since the function names would be more-or-less synonimous ("get", "extract", ... ?). Another scheme would be to have distinct names for these methods within ArrayToken and just overload the arrayname(-) syntax in the expression language. Tobin ---------------------------------------------------------------------------- Posted to the ptolemy-hackers mailing list. Please send administrative mail for this list to: [EMAIL PROTECTED]