3 ms·
I'm not a lisp expert, but my understanding is that CLOS uses packages for this. In CLOS, methods (generic functions) live outside classes. So, like normal fun
by dunham 18y ago
I'm not a lisp expert, but my understanding is that CLOS uses packages for this.
In CLOS, methods (generic functions) live outside classes. So, like normal functions, their names are qualified by the packages that they are defined in. If you want the 'sum' method declared in package 'foo', you either import it into the package/namespace you're working in, or you fully qualify the name ('foo::sum', I think).
This lets you extend built-in classes within your package without getting in anyone else's way.
- gruseom 18y agoGreat explanation. It doesn't really have to do with CLOS though. The package system works on any names whether you use classes or not (we don't). One little detail I love because it illustrates Lisp's design style nicely. If you're using an exported (public) name, you say foo:sum. But if the name is private and you want to breach encapsulation to get at it, you say foo::sum. The language makes you state your intention, but makes it easy to do so and doesn't get in your way.