|
|
Friday, November 29, 2002 |
Blocks vs. FunctionsThere's been a bit of writing on blocks lately. I think blocks are cool, but I'd much rather see a more general purpose functional construct added to Java. In functional languages you have the notion of a thing that returns a value of a given type. This is really handy for doing, well, just about everything. It's desperately missing from Java. When creating a new function inline we will really want to have the context that surrounds the function available to us. What is the best behavior to have here? The only thing I can think of that will really work is to provide a copy of the functions context. Can we really have the function block doing things that will modify the context it comes from? That's a pretty big can of worms. A copy means that we don't have to worry too much about it. Or, we can just check for the variables that are actually used by the inline function, and make sure those are initialized correctly. A change to any of those variables is not reflected in the surrounding environment.
3:43:43 PM |