[Tutor] Apply() [function calling depends on end parent
hese s]
alan.gauld@bt.com
alan.gauld@bt.com
Fri Feb 7 08:28:02 2003
> > It certainly doesn't, which is one reason they had to introduce the
> > dreadful inner class stuff!
> >
> be that I'm still a relative newcomer to Java, too. I thought that
> Java's inner classes were a means of simulating multiple
> inheritance.
Yes, you can use them for that too, that's why I said 'one reason'
Inner classes are a horrible way to provide work-arounds for a lot
of fundamental flaws in the original language.
> And I thought that anonymous inner classes were primarily
> used for code organization, say you need an event handler
> for some control
Which is very often what you use lambdas for in Python.
call back functions in Tkinter etc.
> then why bother making a separate public class just for
> that one case
Which is exactly the argument for lambdas - why bother
creating a function for a one-off use.
> I have not had opportunity to use inner classes in the way that you
> describe (to make dynamic callables), but yes, it does sound
> like a lot more work than the Python way.
Yes, and its the only way to approximate dynamic dispatch in Java.
eg Tables of functions where you want to walk down the table
calling each function but changing the content of the table between
runs, or even as you go!
Alan g.