Skip to content

CLOS Notes

Ashok Khanna edited this page Dec 26, 2021 · 3 revisions

Typically two approaches to naming slot accessors:

  • slot name
  • class name - slot name (or more accurately protocol name - slot name)

Use the former where multiple classes have this as a slot (i.e. the slot is itself a distinct object) and use the latter when the slot makes no sense on its own and is a subcomponent. When in doubt, go with the former

With the former, you should create the class for the slot and then inherit it to make the above clear

Better to inherit a class then to set a slot to it as this way you dont need two levels of access to read the class (first to get the slot / class then to access its slots)

typically keep protocols in one file

multi methods vs defining classes and specialising: depends on whether you need to transfer the whole object

interface vs implementation

storing multiple values -> if passing multiple values, classes makes sense but if only one value then consider normal functions and return values -> classes should be exposed whereas for area you want to isolate you can stick to local/internal functions to signify locality

separating cond statements and control flow from a function to multiple functions

protocols represent both code and data and are an organizational tool

We should try to be as modular as possible, thus every class should be in general defined

Clone this wiki locally