from Hacker News

Mixins in Common Lisp

by Abhinav2000 on 11/22/21, 3:14 AM with 1 comments

  • by pfdietz on 11/22/21, 3:39 AM

    Mixins play nicely with Common Lisp's method combinations, as one can attach a little bit of behavior to each mixin then use MC to weave them together. For example: suppose we want to build classes for the nodes of an abstract syntax tree. We create a mixin for each child slot, and produce a node class by subclassing from the appropriate child slot classes. A traversal function on ASTs assembles traversal methods for these mixin classes using the PROGN method combination.