From: Eric B. R. <eb...@tc...> - 2003-07-31 01:41:17
|
On Wednesday, July 30, 2003, at 09:13 PM, Brian Goetz wrote: > >> By "local functions", you mean local to a Context, right? I'd like to >> see this stay around. The advantages of being able to add my own >> functions w/o editing wm.properties are many, imho. > > I like the idea of being able to put Function objects in the context, > but I don't particularly like how it works now. > > Instead of putFunction(), I like better the idea of putting Function > objects into the context like variables: > > put("cos", new FunctionWrapper(mathObject, "cosine")); This might be too much to ask, but you need 3 things for the Function, right? a name, an object (or Class instance), and a method name (or java.lang.reflect.Method instance maybe?). Couldn't we have put (String variableName, Object obj, String methodName); or put (String variableName, Object obj, java.lang.relfect.Method method); Why should the user be forced to create a new FunctionWrapper? I realize I'm probably contradicting myself based on things I've said previously, but this wouldn't be magical so much as it would be a convenience. > > and then, instead of having Context look up in this special function > map, just look up the name in the context. I don't really like that > there are so many namespaces. > > Then, global functions can work that way too -- they get faulted into > the context the first time you use them. The result is a flat > namespace for variables, tools, functions, etc, and a general purpose > "stuff-on-fault" mechanism for global hoosits. > > Or is that too much magic? It uses magic to cleanup Context.java... Magic for good, not for evil. eric |