Sometimes it is pretty handy to pass through functions to other functions (as is done in functional languages). Such a feature should also exist in Java. These functions could heavily simplify eventhandlers and other listeners, eventually even thread development can be simplified like this. The following illustrates what I mean:
Old non-functional implementation
class SomeFrame extends Frame {
Button button = new Button(...);
SomeFrame {
...
button.addActionListener(new ActionListener(this) {
public void actionPerformed(ActionEvent e) {
buttonClicked(e)
}
});
...
}
public void buttonClicked(ActionEvent e) {...}
}
Functional implementation, much simpler:
class SomeFrame extends Frame {
Button button = new Button(...);
SomeFrame {
...
button.addActionEvent(function this.buttonClicked);
...
}
public void buttonClicked(ActionEvent e) {...}
}
// Somewhere in Button should be:
...
void addActionEvent(void function(ActionEvent), func) {...}
...
It should then also be possible to make collections out of functions.
Suggestions please...