by loup-vaillant · 13y ago · 0 comments
With first class function, you hardly need class polymorphism. Just pass the function as argument already, don't bother with writing a whole new class just to override one method.
The other use for inheritance is plain code reuse. This is bad most of the time because it promotes thick interfaces, and function calls are great at code reuse anyway.
Here, here! After returning to functional programming after a 30 year hiatus, I am beginning to realize just how detrimental the OO orthodoxy has been, and just how impoverished the world has been without first class functions. If only Scheme had caught on in the mainstream when it was invented, the programming world would be a much happier and safer place.
Where, where? ITYM "Hear! Hear!"
http://en.wikipedia.org/wiki/Hear,_hear
"Hear, hear is an expression used as a short, repeated form of hear him, hear him. It represents a listener's agreement with the point being made by a speaker."
Modules (at least in Python) are singletons.
struct foo {
int bar;
float baz;
};
int get_bar(foo);
float get_baz(foo);
Which would emulate this: class foo {
public:
int get_bar();
float get_baz();
private:
int bar;
float baz;
};
If you're interested, I wrote more about that here: http://loup-vaillant.fr/articles/classes-as-syntactic-sugar