5.1.1 New Option Classes

Clon maintains a class hierarchy for all option types. The mother of all option types is the option abstract class. It handles the options’short and long names, description and associated environment variable (see Common Properties). Valued options inherit from an abstract subclass of option called valued-option. This class handles the option’s argument name and status (optional or mandatory), fallback and default values (see Common Valued Option Properties).

In order to create a new option type, use the defoption macro.


Create a new option CLASS and register it with Clon. Syntactically, thismacro behaves like defclass. Option types created like this implicitely inherit from valued-option and in turn option, so you don’t need to put them explicitely in the SUPERCLASSES list.

Let’s look at the enumeration example now.

(defoption enum (enum-base)
  ((argument-name ;; inherited from the VALUED-OPTION class
    :initform "TYPE"))
  (:documentation "The ENUM class.
This class implements options whose values belong to a set of keywords."))

As you can see, this class inherits from enum-base, which is the class handling the :enum property. The reason for this split is that there are currently two option types providing enumeration-like facility: enum and xswitch, so xswitch also inherits from enum-base.

There are no new slots in this class, but the argument-name slot provided by the valued-option class has its initform changed from "ARG" to "TYPE".