In Javascript you cannot use normal methods with functional programming, because 'this' then doesn't refer to the right object anymore. In Higher Order Programming in Javascript I discuss a trick to make this work.
Now I wonder how other languages solve this?
Does the same trick work in Java?
Update: Dan Shappir told me this is what Microsoft's Delegates are about, and Sun's Inner Classes. You can read more about that here. In what languages is it by default possible to pass object methods as functions, where 'this' or something similar always points to the object?
|