▲ | MarsIronPI 4 days ago | ||||||||||||||||
> I'm not sure if that's what you meant; the ML approach is quite different. There is a difference in approach because in Common Lisp each method is a separate function definition (though macros can alleviate this), but my point is that both CL and ML are more function-oriented, if you will; i.e. "methods" (or whatever you want to call ML pattern-matched functions) aren't defined in a class body and are just ordinary functions. I think this more function-focused approach is more elegant, but also more extensible and possibly less verbose when dealing with multiple classes that share the same interface. > the same as in Python except that you also have to define the generic function itself before you can define the methods. As a side note, though it's not terribly important, the "defgeneric" can be omitted if you don't care to specify docstring or any special behavior. | |||||||||||||||||
▲ | kragen 4 days ago | parent [-] | ||||||||||||||||
Oh, thanks! I didn't know that about defgeneric. How would you classify Ruby? You can reopen a class and add more methods to it at any time. | |||||||||||||||||
|