2 ms·
CLOS had excellent facilities for defining functions specific to certain types, but not owned by them. Interfaces and Mix-ins are ways you can deal with this i
by stcredzero 18y ago
CLOS had excellent facilities for defining functions specific to certain types, but not owned by them. Interfaces and Mix-ins are ways you can deal with this in a "noun-oriented" way. (Templates can be used like this as well.)
However, if you just need a function specific to two types, why not just define a function for those types?
In Smalltalk, you'd just use a block with no arguments and hopefully write Unit Tests to cover type inconsistencies. This block would have to sit around somewhere in a method where it is defined, however. Or, you could implement the #value:value: message somewhere and pretend something else is a code block. (There is a similar mechanism in Python, but I can't recall it.)