Not a fan of methods.
Why should the first argument be so special? And how do you decide which struct should get method if you have a function that operates on two different types?
Why should the first argument be so special? And how do you decide which struct should get method if you have a function that operates on two different types?
You don't have to decide where to put the implementation if you dont want to, its just a type of inlining
void foo(Type1 arg1, Type2 arg2) {
// do something
}
class Type1 {
void foo(Type2 arg) {
foo(this, arg);
}
}
class Type2 {
void foo(Type1 arg) {
foo(arg, this);
}
}
vs class Type1 {
void foo(Type2 arg) {
// do something
}
}
class Type2 {
void foo(Type1 arg) {
arg.foo(this);
}
} (defmethod binary-search (object (collection Sequence) before?)
...)
(defmethod binary-search (object (collection Vector) before?)
...)
...and so on. You could even specialize on everything but the first argument.