|
|
|
|
|
by Roboprog
4879 days ago
|
|
Sure, which you can use the following ways: * C: function pointer * Pascal/Delphi: procedural type * JavaScript: function/expression as r-value (weakly typed) * C#: delegate * Java: er, ah, well, I guess you're screwed, as there is no way to pass that function around to other functions. Maybe in Java version N+1! (or Scala or Groovy) -- that is, a static function is even worse than a "virtual" function, since you cannot even pass an object/class/interface as a way to call that function (method). |
|
* Pascal: It's been a decade since I last looked at it, but I don't know if procedural type can be passed around.
* Java: Yep, Java doesn't have first class functions. Will give you that. However, in his example, Yegge was talking as if everything in Java has to be a object, and that somehow functions cannot be called without an associated object.
If you think C function pointers are a valid argument, I can provide a similar hack in java
http://pastebin.com/cSJ8ffar
You can call as many methods as you want. It is disturbing to me when people think C is some holy grail. C, at it is best, is conceptually weak. It is great for working with hardware, but for language features, it would be at the bottom of my list to look at.