The incongruent-methods Reference Manual
Table of Contents
The incongruent-methods Reference Manual
This is the incongruent-methods Reference Manual, version 0.1,
generated automatically by Declt version 3.0 "Montgomery Scott"
on Tue Dec 22 13:51:55 2020 GMT+0.
1 Introduction
* Incongruent methods
** Basics
Incongruent methods is a simple implementation of
incongruent (overloaded) methods using standard CLOS methods. These
methods do not support &key, &rest, &optional etc.
Example:
(define-incongruent-method hello ((me string))
(concatenate 'string "Hello, " me))
(define-incongruent-method hello ((me string) (greeting string))
(concatenate 'string greeting ", " me))
(hello "world")
==> "Hello world"
(hello "world" "Hey")
==> "Hey world"
Example 2:
(defclass hello ()
((message :initarg :message
:initform nil
:accessor %get-message))) ;; standard generic accessor.
(define-incongruent-method greet ((me hello))
(print (%get-message me)))
(define-incongruent-method greet ((me hello) (n integer))
(dotimes (m n)
(greet me)))
** Shared methods
Methods that are "shared" between packages can be also be defined.
These methods can be called using the "imcall" function. It is
advisable that shared methods are specialized on at least one class
defined in your own system. A shared method specializing only on,
say, the built-in integer class, might accidentally get redefined by
other systems.
- Operations that are part of the "public interface" of a class are
good candidates for shared methods.
- In the following example, notice how the call to "notify" in the
do-something method refers to test-package-1::notify, not
test-package-2::notify. In fact, test-package-1 has no knowledge of
the other package and can be compiled separately if one wishes.
Example:
(defpackage :test-package-1
(:use :cl :incongruent-methods)
(:export #:my-class))
(in-package :test-package-1)
(defclass my-class ()
((slot :accessor %get-slot)))
(define-shared-method slot-contents ((me my-class))
(slot-value me 'slot))
(define-shared-method get-something ((me my-class))
'something)
(define-shared-method do-something ((me my-class)
(object t))
(format t "I did something!~%")
(imcall 'notify object :done))
;;;;
(defpackage :test-package-2
(:use :cl :incongruent-methods))
(in-package :test-package-2)
(defclass some-random-class () ())
(define-shared-method notify ((me some-random-class)
(status symbol))
(format t "Received status: ~A~%" status))
(defun main ()
(let ((my-object (make-instance 'test-package-1:my-class))
(some-object (make-instance 'some-random-class)))
(format t "~S~%" (imcall 'get-something my-object))
(imcall 'do-something my-object some-object)))
CL-USER> (main)
==>
TEST-PACKAGE-1::SOMETHING
I did something!
Received status: DONE
** Define-class
A convenience macro for defining classes is also provided. The
symbol "ME" in the body of the methods means the current object (self,
this etc). It should also be the first argument when calling methods
defined using this macro. Accessors will be converted to incongruent
methods.
Example:
(define-class greeting ()
((message :accessor message :initform nil)
(some-slot :accessor some-slot :initform nil))
;; Methods can be defined here, if one wants.
(greet () ;; lambda list is actually ((me greeting))
(message me))
(greet ((n integer)) ;; lambda list is actually ((me greeting) (n integer))
(dotimes (m n)
(greet me)))
(greet ((n (eql 42)))
(some-slot me))
((setf greet) (new)
(setf (message me) new)))
(let ((i (make-instance 'greeting :message "Hello")))
(greet i))
==> "Hello"
(let ((i (make-instance 'greeting :message "Hello")))
(setf (greet i) "Hi")
(greet i))
==> "Hi"
2 Systems
The main system appears first, followed by any subsystem dependency.
2.1 incongruent-methods
- Author
Peter von Etter
- License
LLGPL
- Description
Methods with incongruent lambda lists.
- Version
0.1
- Dependency
closer-mop
- Source
incongruent-methods.asd (file)
- Components
-
3 Files
Files are sorted by type and then listed depth-first from the systems
components trees.
3.1 Lisp
3.1.1 incongruent-methods.asd
- Location
incongruent-methods.asd
- Systems
incongruent-methods (system)
3.1.2 incongruent-methods/package.lisp
- Parent
incongruent-methods (system)
- Location
package.lisp
- Packages
incongruent-methods
3.1.3 incongruent-methods/incongruent-methods.lisp
- Dependency
package.lisp (file)
- Parent
incongruent-methods (system)
- Location
incongruent-methods.lisp
- Exported Definitions
-
- Internal Definitions
-
3.1.4 incongruent-methods/shared-methods.lisp
- Dependency
incongruent-methods.lisp (file)
- Parent
incongruent-methods (system)
- Location
shared-methods.lisp
- Packages
incongruent-methods.methods
- Exported Definitions
-
- Internal Definitions
-
3.1.5 incongruent-methods/class-methods.lisp
- Dependency
shared-methods.lisp (file)
- Parent
incongruent-methods (system)
- Location
class-methods.lisp
- Exported Definitions
-
- Internal Definitions
-
4 Packages
Packages are listed by definition order.
4.1 incongruent-methods
- Source
package.lisp (file)
- Use List
common-lisp
- Exported Definitions
-
- Internal Definitions
-
4.2 incongruent-methods.methods
- Source
shared-methods.lisp (file)
5 Definitions
Definitions are sorted by export status, category, package, and then by
lexicographic order.
5.1 Exported definitions
5.1.1 Macros
- Macro: define-class NAME DIRECT-SUPERCLASSES DIRECT-SLOTS &body METHODS
-
- Package
incongruent-methods
- Source
class-methods.lisp (file)
- Macro: define-class-method NAME METHOD-LAMBDA-LIST &body BODY
-
- Package
incongruent-methods
- Source
class-methods.lisp (file)
- Macro: define-incongruent-method NAME METHOD-LAMBDA-LIST &body BODY
-
- Package
incongruent-methods
- Source
incongruent-methods.lisp (file)
- Macro: define-shared-method NAME METHOD-LAMBDA-LIST &body BODY
-
- Package
incongruent-methods
- Source
shared-methods.lisp (file)
5.1.2 Compiler macros
- Compiler Macro: imcall METHOD &rest ARGS
-
- Package
incongruent-methods
- Source
shared-methods.lisp (file)
5.1.3 Functions
- Function: (setf imcall) NEW METHOD &rest ARGS
-
- Package
incongruent-methods
- Source
shared-methods.lisp (file)
- Reader
imcall (generic function)
- Function: list-incongruent-methods NAME
-
- Package
incongruent-methods
- Source
incongruent-methods.lisp (file)
- Function: list-shared-methods NAME
-
- Package
incongruent-methods
- Source
shared-methods.lisp (file)
- Function: remove-incongruent-function NAME
-
- Package
incongruent-methods
- Source
incongruent-methods.lisp (file)
5.1.4 Generic functions
- Generic Function: imcall METHOD &rest ARGS
-
- Package
incongruent-methods
- Source
shared-methods.lisp (file)
- Writer
(setf imcall) (function)
- Methods
- Method: imcall (METHOD symbol) &rest ARGS
-
5.2 Internal definitions
5.2.1 Special variables
- Special Variable: *class-principal-methods*
-
- Package
incongruent-methods
- Source
class-methods.lisp (file)
- Special Variable: *generic-arity-functions*
-
- Package
incongruent-methods
- Source
incongruent-methods.lisp (file)
- Special Variable: *indentation-hints*
-
- Package
incongruent-methods
- Source
class-methods.lisp (file)
- Special Variable: *method-package*
-
- Package
incongruent-methods
- Source
shared-methods.lisp (file)
- Special Variable: *methods-with-arity*
-
- Package
incongruent-methods
- Source
incongruent-methods.lisp (file)
- Special Variable: *setf-methods-with-arity*
-
- Package
incongruent-methods
- Source
incongruent-methods.lisp (file)
5.2.2 Macros
- Macro: clear-class-methods NAME
-
- Package
incongruent-methods
- Source
class-methods.lisp (file)
- Macro: internf-shared-method PLACE
-
- Package
incongruent-methods
- Source
shared-methods.lisp (file)
5.2.3 Functions
- Function: %add-method-with-arity NAME ARITY TABLE &optional SETF
-
- Package
incongruent-methods
- Source
incongruent-methods.lisp (file)
- Function: %find-method GF QUALIFIERS SPECIALIZERS &optional ERRORP
-
- Package
incongruent-methods
- Source
class-methods.lisp (file)
- Function: %find-method-with-arity NAME ARITY TABLE
-
- Package
incongruent-methods
- Source
incongruent-methods.lisp (file)
- Function: %remove-method-with-arity NAME ARITY TABLE
-
- Package
incongruent-methods
- Source
incongruent-methods.lisp (file)
- Function: add-class-principal-method NAME METHOD-LAMBDA-LIST
-
- Package
incongruent-methods
- Source
class-methods.lisp (file)
- Function: bad-lambda-list-p LAMBDA-LIST
-
- Package
incongruent-methods
- Source
incongruent-methods.lisp (file)
- Function: clear-shared-methods ()
-
- Package
incongruent-methods
- Source
shared-methods.lisp (file)
- Function: dispatcher-compiler-macro FORM
-
- Package
incongruent-methods
- Source
incongruent-methods.lisp (file)
- Function: ensure-dispatcher NAME
-
- Package
incongruent-methods
- Source
incongruent-methods.lisp (file)
- Function: ensure-generic-arity-function NAME ARITY
-
- Package
incongruent-methods
- Source
incongruent-methods.lisp (file)
- Function: error-on-bad-lambda-list NAME LAMBDA-LIST
-
- Package
incongruent-methods
- Source
incongruent-methods.lisp (file)
- Function: find-bound-symbol SYMBOL PACKAGE
-
- Package
incongruent-methods
- Source
class-methods.lisp (file)
- Function: list-class-principal-methods CLASS-NAME
-
- Package
incongruent-methods
- Source
class-methods.lisp (file)
- Function: list-incongruent-generic-functions NAME
-
- Package
incongruent-methods
- Source
incongruent-methods.lisp (file)
- Function: method-lambda-list-arity LAMBDA-LIST
-
- Package
incongruent-methods
- Source
incongruent-methods.lisp (file)
- Function: method-parameter-name X
-
- Package
incongruent-methods
- Source
incongruent-methods.lisp (file)
- Function: method-parameter-type X
-
- Package
incongruent-methods
- Source
incongruent-methods.lisp (file)
- Function: remove-class-principal-methods CLASS-NAME
-
- Package
incongruent-methods
- Source
class-methods.lisp (file)
- Function: setf-method-p NAME
-
- Package
incongruent-methods
- Source
incongruent-methods.lisp (file)
- Function: update-indentation-hints ()
-
- Package
incongruent-methods
- Source
class-methods.lisp (file)
- Function: without-props PLIST PROPS
-
- Package
incongruent-methods
- Source
class-methods.lisp (file)
5.2.4 Generic functions
- Generic Function: add-method-with-arity NAME ARITY
-
- Package
incongruent-methods
- Source
incongruent-methods.lisp (file)
- Methods
- Method: add-method-with-arity (NAME list) ARITY
-
- Method: add-method-with-arity (NAME symbol) ARITY
-
- Generic Function: find-method-with-arity NAME ARITY
-
- Package
incongruent-methods
- Source
incongruent-methods.lisp (file)
- Methods
- Method: find-method-with-arity (NAME list) ARITY
-
- Method: find-method-with-arity (NAME symbol) ARITY
-
- Generic Function: find-setf-method-with-arity NAME ARITY
-
- Package
incongruent-methods
- Source
incongruent-methods.lisp (file)
- Methods
- Method: find-setf-method-with-arity (NAME symbol) ARITY
-
- Generic Function: find-shared-method NAME
-
- Package
incongruent-methods
- Source
shared-methods.lisp (file)
- Methods
- Method: find-shared-method (NAME list)
-
- Method: find-shared-method (NAME string)
-
- Method: find-shared-method (NAME symbol)
-
- Generic Function: incongruent-function-p NAME
-
- Package
incongruent-methods
- Source
incongruent-methods.lisp (file)
- Methods
- Method: incongruent-function-p NAME
-
- Generic Function: intern-shared-method THING
-
- Package
incongruent-methods
- Source
shared-methods.lisp (file)
- Methods
- Method: intern-shared-method (NAME list)
-
- Method: intern-shared-method (NAME symbol)
-
- Generic Function: method-name-with-arity NAME ARITY
-
- Package
incongruent-methods
- Source
incongruent-methods.lisp (file)
- Methods
- Method: method-name-with-arity (NAME list) ARITY
-
- Method: method-name-with-arity (NAME symbol) ARITY
-
- Generic Function: remove-method-with-arity NAME ARITY
-
- Package
incongruent-methods
- Source
incongruent-methods.lisp (file)
- Methods
- Method: remove-method-with-arity (NAME list) ARITY
-
- Method: remove-method-with-arity (NAME symbol) ARITY
-
- Generic Function: send OBJECT METHOD &rest ARGS
-
- Package
incongruent-methods
- Source
shared-methods.lisp (file)
Appendix A Indexes
A.1 Concepts
| Index Entry | | Section |
|
F | | |
| File, Lisp, incongruent-methods.asd: | | The incongruent-methods․asd file |
| File, Lisp, incongruent-methods/class-methods.lisp: | | The incongruent-methods/class-methods․lisp file |
| File, Lisp, incongruent-methods/incongruent-methods.lisp: | | The incongruent-methods/incongruent-methods․lisp file |
| File, Lisp, incongruent-methods/package.lisp: | | The incongruent-methods/package․lisp file |
| File, Lisp, incongruent-methods/shared-methods.lisp: | | The incongruent-methods/shared-methods․lisp file |
|
I | | |
| incongruent-methods.asd: | | The incongruent-methods․asd file |
| incongruent-methods/class-methods.lisp: | | The incongruent-methods/class-methods․lisp file |
| incongruent-methods/incongruent-methods.lisp: | | The incongruent-methods/incongruent-methods․lisp file |
| incongruent-methods/package.lisp: | | The incongruent-methods/package․lisp file |
| incongruent-methods/shared-methods.lisp: | | The incongruent-methods/shared-methods․lisp file |
|
L | | |
| Lisp File, incongruent-methods.asd: | | The incongruent-methods․asd file |
| Lisp File, incongruent-methods/class-methods.lisp: | | The incongruent-methods/class-methods․lisp file |
| Lisp File, incongruent-methods/incongruent-methods.lisp: | | The incongruent-methods/incongruent-methods․lisp file |
| Lisp File, incongruent-methods/package.lisp: | | The incongruent-methods/package․lisp file |
| Lisp File, incongruent-methods/shared-methods.lisp: | | The incongruent-methods/shared-methods․lisp file |
|
A.2 Functions
| Index Entry | | Section |
|
% | | |
| %add-method-with-arity : | | Internal functions |
| %find-method : | | Internal functions |
| %find-method-with-arity : | | Internal functions |
| %remove-method-with-arity : | | Internal functions |
|
( | | |
| (setf imcall) : | | Exported functions |
|
A | | |
| add-class-principal-method : | | Internal functions |
| add-method-with-arity : | | Internal generic functions |
| add-method-with-arity : | | Internal generic functions |
| add-method-with-arity : | | Internal generic functions |
|
B | | |
| bad-lambda-list-p : | | Internal functions |
|
C | | |
| clear-class-methods : | | Internal macros |
| clear-shared-methods : | | Internal functions |
| Compiler Macro, imcall : | | Exported compiler macros |
|
D | | |
| define-class : | | Exported macros |
| define-class-method : | | Exported macros |
| define-incongruent-method : | | Exported macros |
| define-shared-method : | | Exported macros |
| dispatcher-compiler-macro : | | Internal functions |
|
E | | |
| ensure-dispatcher : | | Internal functions |
| ensure-generic-arity-function : | | Internal functions |
| error-on-bad-lambda-list : | | Internal functions |
|
F | | |
| find-bound-symbol : | | Internal functions |
| find-method-with-arity : | | Internal generic functions |
| find-method-with-arity : | | Internal generic functions |
| find-method-with-arity : | | Internal generic functions |
| find-setf-method-with-arity : | | Internal generic functions |
| find-setf-method-with-arity : | | Internal generic functions |
| find-shared-method : | | Internal generic functions |
| find-shared-method : | | Internal generic functions |
| find-shared-method : | | Internal generic functions |
| find-shared-method : | | Internal generic functions |
| Function, %add-method-with-arity : | | Internal functions |
| Function, %find-method : | | Internal functions |
| Function, %find-method-with-arity : | | Internal functions |
| Function, %remove-method-with-arity : | | Internal functions |
| Function, (setf imcall) : | | Exported functions |
| Function, add-class-principal-method : | | Internal functions |
| Function, bad-lambda-list-p : | | Internal functions |
| Function, clear-shared-methods : | | Internal functions |
| Function, dispatcher-compiler-macro : | | Internal functions |
| Function, ensure-dispatcher : | | Internal functions |
| Function, ensure-generic-arity-function : | | Internal functions |
| Function, error-on-bad-lambda-list : | | Internal functions |
| Function, find-bound-symbol : | | Internal functions |
| Function, list-class-principal-methods : | | Internal functions |
| Function, list-incongruent-generic-functions : | | Internal functions |
| Function, list-incongruent-methods : | | Exported functions |
| Function, list-shared-methods : | | Exported functions |
| Function, method-lambda-list-arity : | | Internal functions |
| Function, method-parameter-name : | | Internal functions |
| Function, method-parameter-type : | | Internal functions |
| Function, remove-class-principal-methods : | | Internal functions |
| Function, remove-incongruent-function : | | Exported functions |
| Function, setf-method-p : | | Internal functions |
| Function, update-indentation-hints : | | Internal functions |
| Function, without-props : | | Internal functions |
|
G | | |
| Generic Function, add-method-with-arity : | | Internal generic functions |
| Generic Function, find-method-with-arity : | | Internal generic functions |
| Generic Function, find-setf-method-with-arity : | | Internal generic functions |
| Generic Function, find-shared-method : | | Internal generic functions |
| Generic Function, imcall : | | Exported generic functions |
| Generic Function, incongruent-function-p : | | Internal generic functions |
| Generic Function, intern-shared-method : | | Internal generic functions |
| Generic Function, method-name-with-arity : | | Internal generic functions |
| Generic Function, remove-method-with-arity : | | Internal generic functions |
| Generic Function, send : | | Internal generic functions |
|
I | | |
| imcall : | | Exported compiler macros |
| imcall : | | Exported generic functions |
| imcall : | | Exported generic functions |
| incongruent-function-p : | | Internal generic functions |
| incongruent-function-p : | | Internal generic functions |
| intern-shared-method : | | Internal generic functions |
| intern-shared-method : | | Internal generic functions |
| intern-shared-method : | | Internal generic functions |
| internf-shared-method : | | Internal macros |
|
L | | |
| list-class-principal-methods : | | Internal functions |
| list-incongruent-generic-functions : | | Internal functions |
| list-incongruent-methods : | | Exported functions |
| list-shared-methods : | | Exported functions |
|
M | | |
| Macro, clear-class-methods : | | Internal macros |
| Macro, define-class : | | Exported macros |
| Macro, define-class-method : | | Exported macros |
| Macro, define-incongruent-method : | | Exported macros |
| Macro, define-shared-method : | | Exported macros |
| Macro, internf-shared-method : | | Internal macros |
| Method, add-method-with-arity : | | Internal generic functions |
| Method, add-method-with-arity : | | Internal generic functions |
| Method, find-method-with-arity : | | Internal generic functions |
| Method, find-method-with-arity : | | Internal generic functions |
| Method, find-setf-method-with-arity : | | Internal generic functions |
| Method, find-shared-method : | | Internal generic functions |
| Method, find-shared-method : | | Internal generic functions |
| Method, find-shared-method : | | Internal generic functions |
| Method, imcall : | | Exported generic functions |
| Method, incongruent-function-p : | | Internal generic functions |
| Method, intern-shared-method : | | Internal generic functions |
| Method, intern-shared-method : | | Internal generic functions |
| Method, method-name-with-arity : | | Internal generic functions |
| Method, method-name-with-arity : | | Internal generic functions |
| Method, remove-method-with-arity : | | Internal generic functions |
| Method, remove-method-with-arity : | | Internal generic functions |
| method-lambda-list-arity : | | Internal functions |
| method-name-with-arity : | | Internal generic functions |
| method-name-with-arity : | | Internal generic functions |
| method-name-with-arity : | | Internal generic functions |
| method-parameter-name : | | Internal functions |
| method-parameter-type : | | Internal functions |
|
R | | |
| remove-class-principal-methods : | | Internal functions |
| remove-incongruent-function : | | Exported functions |
| remove-method-with-arity : | | Internal generic functions |
| remove-method-with-arity : | | Internal generic functions |
| remove-method-with-arity : | | Internal generic functions |
|
S | | |
| send : | | Internal generic functions |
| setf-method-p : | | Internal functions |
|
U | | |
| update-indentation-hints : | | Internal functions |
|
W | | |
| without-props : | | Internal functions |
|
A.3 Variables
A.4 Data types