The nclasses Reference Manual

This is the nclasses Reference Manual, version 0.2.0, generated automatically by Declt version 4.0 beta 2 "William Riker" on Wed Mar 15 07:05:10 2023 GMT+0.

Table of Contents


1 Systems

The main system appears first, followed by any subsystem dependency.


1.1 nclasses

Simplify class like definitions with define-class and friends.

Maintainer

Atlas Engineer LLC

Author

dwim.hu & Atlas Engineer LLC

Home Page

https://github.com/atlas-engineer/nclasses

License

Public Domain

Version

0.2.0

Dependency

moptilities (system).

Source

nclasses.asd.

Child Components

2 Files

Files are sorted by type and then listed depth-first from the systems components trees.


2.1 Lisp


2.1.1 nclasses/nclasses.asd

Source

nclasses.asd.

Parent Component

nclasses (system).

ASDF Systems

nclasses.


2.1.2 nclasses/package.lisp

Source

nclasses.asd.

Parent Component

nclasses (system).

Packages

nclasses.


2.1.3 nclasses/duplicates.lisp

Dependency

package.lisp (file).

Source

nclasses.asd.

Parent Component

nclasses (system).

Internals

2.1.4 nclasses/defclass-star.lisp

Dependency

duplicates.lisp (file).

Source

nclasses.asd.

Parent Component

nclasses (system).

Public Interface
Internals

3 Packages

Packages are listed by definition order.


3.1 nclasses

This library offers two helper macros:
- ‘nclasses:define-class’
- ‘nclasses:define-condition*’.

Compared to the standard macros, they accept extra options and slot definition
is smarter.

Example:

(define-class foo ()
((slot1 :initarg nil)
(slot2 "hello!")
(unexported-slot :export nil))
(:export-class-name-p t)
(:export-accessor-names-p t)
(:accessor-name-transformer #’nclasses:default-accessor-name-transformer))

In the above, all slot accessors are automatically defined using ‘nclasses:default-accessor-name-transformer’. They are also exported together with the class name.
The initarg default to the keyword version of the slot symbol, unless it’s explicitly set to NIL.

Notice that the second value of the slot definition, if not an option, is then
the initform.

See ‘nclasses:define-class’ for more details.

Source

package.lisp.

Use List

common-lisp.

Public Interface
Internals

4 Definitions

Definitions are sorted by export status, category, package, and then by lexicographic order.


4.1 Public Interface


4.1.1 Special variables

Special Variable: *allowed-slot-definition-properties*

Holds a list of keywords that are allowed in slot definitions (:accessor and :initarg are implicitly included).

Package

nclasses.

Source

defclass-star.lisp.


4.1.2 Macros

Macro: define-class (name supers slots &rest options)

Convenience wrapper of ‘defclass’.

It automates a lot of boilerplate (like exporting all the accessors of a class)
plus adds some new features.

Slot options:

- The initform can be specified as the second value.

- ‘:accessor’, ‘:reader’ and ‘:writer’ can be set to either a name, NIL or T.
If NIL, the method is not generated.
If T, the method is generated using the ‘:accessor-name-transformer’ class option value.

- The ‘:export’ option allows to control the slot-name export on a per-slot basis.

New class options (defaults are NIL unless specified):

- ‘:slot-definition-transformer’ (default: ‘default-slot-definition-transformer’).
A function that takes a SLOT-DEFINITION and returns a new one.

- ‘:accessor-name-package’: The package of the generated accessors. See ‘:accessor-name-transformer’. Some special values are accepted:
- ‘:slot-name’: The package of the slot-name.
- ‘:default’: The current package.

- ‘:accessor-name-transformer’ (default ‘default-accessor-name-transformer’).

A function of (SLOT-NAME SLOT-DEFINITION) arguments that returns the accessor
name (a symbol). Other transformer: ‘dwim-accessor-name-transformer’.

- ‘:automatic-accessors-p’: Whether to generate accessor names automatically for
all slots.

- ‘:initarg-name-transformer’ (default: ‘default-initarg-name-transformer’.)

A function of (SLOT-NAME SLOT-DEFINITION) arguments that returns the accessor
name (a symbol.

- ‘:automatic-initargs-p’ (default: T): Whether to generate accessor names automatically for all slots.

- ‘:predicate-name-transformer’ (default: ‘default-predicate-name-transformer’).

A function of (SLOT-NAME SLOT-DEFINITION) arguments that returns the predicate
name (a symbol).

- ‘:automatic-predicates-p’ (default: T): Whether to generate a predicate
for the class.

- ‘:type-inference’ (default: ‘default-type-inference’).

Function that returns the type of a slot definition (with an initform). It
takes 3 arguments:

- The initform.
- The slot name.
- The rest of the slot definition.

- ‘:automatic-types-p’: Whether to generate the type automatically for all
slots. The type can still be specified manually with the ‘:type’ slot option.

- Self-explanatory export options (all NIL by default):
- ‘:export-class-name-p’
- ‘:export-accessor-names-p’
- ‘:export-slot-names-p’
- ‘:export-predicate-name’

Package

nclasses.

Source

defclass-star.lisp.

Macro: define-condition* (name supers slots &rest options)

To ‘define-condition’ what ‘define-class’ is to ‘defclass’. See ‘define-class’ for more details.

Package

nclasses.

Source

defclass-star.lisp.

Macro: make-name-transformer (&rest elements)

Return an accessor name transformer.
The unquoted ‘name’ symbol argument is substituted for the slot name. Class option examples:

:accessor-name-transformer (make-name-transformer "FOO-" name "-BAR")

Use the slot name directly:

:accessor-name-transformer (make-name-transformer name)

Package

nclasses.

Source

defclass-star.lisp.


4.1.3 Ordinary functions

Function: always-dashed-predicate-name-transformer (name &rest args)

Return predicate name that’s always suffixed with ’-p’.

Package

nclasses.

Source

defclass-star.lisp.

Function: default-accessor-name-transformer (name definition)

Return an accessor name following the slot name NAME.

Package

nclasses.

Source

defclass-star.lisp.

Function: default-initarg-name-transformer (name definition)
Package

nclasses.

Source

defclass-star.lisp.

Function: default-predicate-name-transformer (name &rest args)

Return predicate name that’s suffixed with ’-p’ if NAME already contains a ’-’, or just ’p’ otherwise..

Package

nclasses.

Source

defclass-star.lisp.

Function: default-slot-definition-transformer (slot-def)

Converts illegal (list foo) :type declarations into simple list declarations.

Package

nclasses.

Source

defclass-star.lisp.

Function: default-type-inference (initform name definition)

Return type of INITFORM.
This is like ‘type-of’ but returns less specialized types for some common subtypes, e.g. for "" return ’string instead of ‘(SIMPLE-ARRAY CHARACTER (0))’.

Note that in a slot definition, ’() is inferred to be a list while NIL is inferred to be a boolean.

If the slot is found in a finalized superclass, the inferred type is then that of the superclass. If some superclass is not finalized, no type inference is performed.

Non-basic form types are not inferred (returns nil).
Non-basic scalar types are derived to their own type (with ‘type-of’).

Package

nclasses.

Source

defclass-star.lisp.

Function: dwim-accessor-name-transformer (name definition)

Return an accessor name using the slot name NAME suffixed with "-OF".
If the slot is a boolean not ending with a question mark, it is suffixed with "-P" instead. If the slot ends with a question mark, the name is taken as is.

Package

nclasses.

Source

defclass-star.lisp.

Function: question-mark-accessor-name-transformer (name definition)

Return an accessor name using the slot name NAME suffixed with "-OF". If the slot is a boolean, it ensures the name is suffixed with "?".

Package

nclasses.

Source

defclass-star.lisp.

Function: question-mark-predicate-name-transformer (name &rest args)

Return predicate name that’s always suffixed with ’?’.

Package

nclasses.

Source

defclass-star.lisp.


4.2 Internals


4.2.1 Special variables

Special Variable: *accessor-name-package*

A package, or :slot-name means the home-package of the slot-name symbol and nil means *package*

Package

nclasses.

Source

defclass-star.lisp.

Special Variable: *accessor-name-transformer*
Package

nclasses.

Source

defclass-star.lisp.

Special Variable: *accessor-names*
Package

nclasses.

Source

defclass-star.lisp.

Special Variable: *automatic-accessors-p*
Package

nclasses.

Source

defclass-star.lisp.

Special Variable: *automatic-initargs-p*
Package

nclasses.

Source

defclass-star.lisp.

Special Variable: *automatic-predicates-p*
Package

nclasses.

Source

defclass-star.lisp.

Special Variable: *automatic-types-p*
Package

nclasses.

Source

defclass-star.lisp.

Special Variable: *export-accessor-names-p*
Package

nclasses.

Source

defclass-star.lisp.

Special Variable: *export-class-name-p*
Package

nclasses.

Source

defclass-star.lisp.

Special Variable: *export-predicate-name-p*
Package

nclasses.

Source

defclass-star.lisp.

Special Variable: *export-slot-names-p*
Package

nclasses.

Source

defclass-star.lisp.

Special Variable: *initarg-name-transformer*
Package

nclasses.

Source

defclass-star.lisp.

Special Variable: *predicate-name-transformer*

A function that takes the class name and its definition as argument.
Return the name of the predicate function.
The predicate function returns true when the argument is a type of the ‘name’ class.

Package

nclasses.

Source

defclass-star.lisp.

Special Variable: *slot-definition-transformer*
Package

nclasses.

Source

defclass-star.lisp.

Special Variable: *slot-names*
Package

nclasses.

Source

defclass-star.lisp.

Special Variable: *symbols-to-export*
Package

nclasses.

Source

defclass-star.lisp.

Special Variable: *type-inference*

Function that returns the type of a slot definition (with an initform). It takes 3 arguments:
- The initform.
- The slot name.
- The rest of the slot definition.

Package

nclasses.

Source

defclass-star.lisp.


4.2.2 Macros

Macro: remf-keywords (place &rest keywords)

Removes the properties identified by KEYWORDS from PLACE.

Package

nclasses.

Source

duplicates.lisp.


4.2.3 Ordinary functions

Function: build-defclass-like-expansion (name supers slots options expansion-builder)
Package

nclasses.

Source

defclass-star.lisp.

Function: concatenate-symbol (&rest args)

Args are processed as parts of the result symbol with two exceptions except when a package is encountered then it is stored as the target package at intern.

Package

nclasses.

Source

duplicates.lisp.

Function: extract-options-into-bindings (options)
Package

nclasses.

Source

defclass-star.lisp.

Function: fully-qualified-symbol-name (symbol &key separator)
Package

nclasses.

Source

duplicates.lisp.

Function: process-slot-definition (definition &key superclasses)
Package

nclasses.

Source

defclass-star.lisp.

Function: remove-keywords (plist &rest keywords)

Creates a copy of PLIST without the listed KEYWORDS.

Package

nclasses.

Source

duplicates.lisp.

Function: slot-name-package (name)
Package

nclasses.

Source

defclass-star.lisp.

Function: slot-type-maybe-inherited (initform slot-name definition superclasses)
Package

nclasses.

Source

defclass-star.lisp.

Function: style-warn (datum &rest args)
Package

nclasses.

Source

defclass-star.lisp.


4.2.4 Conditions

Condition: hu.dwim.defclass-star-style-warning
Package

nclasses.

Source

defclass-star.lisp.

Direct superclasses
  • simple-condition.
  • style-warning.

Appendix A Indexes


A.1 Concepts


A.2 Functions

Jump to:   A   B   C   D   E   F   M   P   Q   R   S  
Index Entry  Section

A
always-dashed-predicate-name-transformer: Public ordinary functions

B
build-defclass-like-expansion: Private ordinary functions

C
concatenate-symbol: Private ordinary functions

D
default-accessor-name-transformer: Public ordinary functions
default-initarg-name-transformer: Public ordinary functions
default-predicate-name-transformer: Public ordinary functions
default-slot-definition-transformer: Public ordinary functions
default-type-inference: Public ordinary functions
define-class: Public macros
define-condition*: Public macros
dwim-accessor-name-transformer: Public ordinary functions

E
extract-options-into-bindings: Private ordinary functions

F
fully-qualified-symbol-name: Private ordinary functions
Function, always-dashed-predicate-name-transformer: Public ordinary functions
Function, build-defclass-like-expansion: Private ordinary functions
Function, concatenate-symbol: Private ordinary functions
Function, default-accessor-name-transformer: Public ordinary functions
Function, default-initarg-name-transformer: Public ordinary functions
Function, default-predicate-name-transformer: Public ordinary functions
Function, default-slot-definition-transformer: Public ordinary functions
Function, default-type-inference: Public ordinary functions
Function, dwim-accessor-name-transformer: Public ordinary functions
Function, extract-options-into-bindings: Private ordinary functions
Function, fully-qualified-symbol-name: Private ordinary functions
Function, process-slot-definition: Private ordinary functions
Function, question-mark-accessor-name-transformer: Public ordinary functions
Function, question-mark-predicate-name-transformer: Public ordinary functions
Function, remove-keywords: Private ordinary functions
Function, slot-name-package: Private ordinary functions
Function, slot-type-maybe-inherited: Private ordinary functions
Function, style-warn: Private ordinary functions

M
Macro, define-class: Public macros
Macro, define-condition*: Public macros
Macro, make-name-transformer: Public macros
Macro, remf-keywords: Private macros
make-name-transformer: Public macros

P
process-slot-definition: Private ordinary functions

Q
question-mark-accessor-name-transformer: Public ordinary functions
question-mark-predicate-name-transformer: Public ordinary functions

R
remf-keywords: Private macros
remove-keywords: Private ordinary functions

S
slot-name-package: Private ordinary functions
slot-type-maybe-inherited: Private ordinary functions
style-warn: Private ordinary functions


A.3 Variables

Jump to:   *  
S  
Index Entry  Section

*
*accessor-name-package*: Private special variables
*accessor-name-transformer*: Private special variables
*accessor-names*: Private special variables
*allowed-slot-definition-properties*: Public special variables
*automatic-accessors-p*: Private special variables
*automatic-initargs-p*: Private special variables
*automatic-predicates-p*: Private special variables
*automatic-types-p*: Private special variables
*export-accessor-names-p*: Private special variables
*export-class-name-p*: Private special variables
*export-predicate-name-p*: Private special variables
*export-slot-names-p*: Private special variables
*initarg-name-transformer*: Private special variables
*predicate-name-transformer*: Private special variables
*slot-definition-transformer*: Private special variables
*slot-names*: Private special variables
*symbols-to-export*: Private special variables
*type-inference*: Private special variables

S
Special Variable, *accessor-name-package*: Private special variables
Special Variable, *accessor-name-transformer*: Private special variables
Special Variable, *accessor-names*: Private special variables
Special Variable, *allowed-slot-definition-properties*: Public special variables
Special Variable, *automatic-accessors-p*: Private special variables
Special Variable, *automatic-initargs-p*: Private special variables
Special Variable, *automatic-predicates-p*: Private special variables
Special Variable, *automatic-types-p*: Private special variables
Special Variable, *export-accessor-names-p*: Private special variables
Special Variable, *export-class-name-p*: Private special variables
Special Variable, *export-predicate-name-p*: Private special variables
Special Variable, *export-slot-names-p*: Private special variables
Special Variable, *initarg-name-transformer*: Private special variables
Special Variable, *predicate-name-transformer*: Private special variables
Special Variable, *slot-definition-transformer*: Private special variables
Special Variable, *slot-names*: Private special variables
Special Variable, *symbols-to-export*: Private special variables
Special Variable, *type-inference*: Private special variables