mighty-gerbils / gerbil

Gerbil Scheme
https://cons.io
GNU Lesser General Public License v2.1
1.16k stars 112 forks source link

generic defmethod does not redefine a method #52

Closed drewc closed 6 years ago

drewc commented 6 years ago

When running defmethod on an already existing method, it uses the old one always, not the redefinition.

Gerbil v0.12-DEV-1038-g4323fa2 on Gambit v4.8.8

(import :std/generic) (defgeneric foo) (defclass A ()) (defmethod (foo (a A)) "A, eh?") (foo (make-A)) "A, eh?" (defclass (B A) ()) (foo (make-B)) "A, eh?" (defmethod (foo (b B)) "B, eh?") (foo (make-B)) "B, eh?" (defmethod (foo (b B)) "Redefine foo for B, eh?") (foo (make-B)) "B, eh?"

fare commented 6 years ago

The object system is known for being in need of much love, indeed :-/

vyzo commented 6 years ago

Yeah, that's a problem that is hard to fix with the current generic dispatch. The generics are scheduled for rewrite soon[TM] and that's one of the problems that will be fixed.

vyzo commented 6 years ago

I think I can fix extend-generic-dispatch-tree to replace a method when it has the same type. Not so hard to fix after all.

vyzo commented 6 years ago

Fixed in https://github.com/vyzo/gerbil/commit/fc658440874859bcf1ba5b978bd6b310a2d8b850