RSS Feed

Lisp Project of the Day

list-named-class

You can support this project by donating at:

Donate using PatreonDonate using Liberapay

Or see the list of project sponsors.

list-named-classlanguageclos

Documentation๐Ÿ˜€
Docstrings๐Ÿฅบ
Tests ๐Ÿ˜€
Examples๐Ÿ˜€
RepositoryActivity๐Ÿฅบ
CI ๐Ÿฅบ

This is the library by Michaล‚ "phoe" Herda. It extends CLOS allowing to use lists of symbols as class names:

POFTHEDAY> (list-named-class:defclass (:user :model) ()
             ())

POFTHEDAY> (list-named-class:defclass (:user :view) ()
             ())

POFTHEDAY> (list-named-class:defgeneric render (obj))

POFTHEDAY> (list-named-class:defmethod render ((obj (:user :view)))
             (format nil "Rendered User View"))

POFTHEDAY> (list-named-class:make-instance '(:user :view))
#<(:USER :VIEW) {10076F6CC3}>

POFTHEDAY> (render *)
"Rendered User View"

This can be useful when classes are defined using some macros. Not sure why somebody should prefer such class-names instead of symbols.

Here are some examples of list-named-class usage I found in the wild:


Brought to you by 40Ants under Creative Commons License