*********************** Classes & Instantiation *********************** Dylan makes it easy to define classes. You don't normally need to write constructors or accessor functions, which saves a lot of boring typing. You can initialize slots (a.k.a. "fields", "member variables", etc.) by providing a default value or expression in the slot spec and the caller may override the value using keyword arguments. A small percentage of classes still need "constructors", which can be defined by overriding :drm:`initialize`. .. code-block:: dylan define class () slot serial-number :: = unique-serial-number(); slot model-name :: , required-init-keyword: model:; slot has-sunroof? :: , init-keyword: sunroof?:, init-value: #f; end class ; define variable *unique-serial-number* = 0; define function unique-serial-number() => (usn :: ) let serial = *unique-serial-number*; *unique-serial-number* := *unique-serial-number* + 1; serial; end function; define constant $blue-car = make(, model: "Viper"); define constant $black-car = make(, model: "Town Car", sunroof?: #t); define constant $red-car = make(, model: "F40", sunroof?: #f);