Documented the new argument order accepted by define-generics.
This commit is contained in:
parent
065622d64b
commit
b9f2e4d541
|
@ -16,21 +16,20 @@ using a @racket[define-generics] form. Method implementations for
|
||||||
a structure type are defined using the @racket[#:methods] keyword
|
a structure type are defined using the @racket[#:methods] keyword
|
||||||
(see @secref["define-struct"]).
|
(see @secref["define-struct"]).
|
||||||
|
|
||||||
@defform/subs[(define-generics id [#:defined-table defined-table-id]
|
@defform/subs[(define-generics id
|
||||||
[method-id . kw-formals*]
|
generics-opt ...
|
||||||
...
|
[method-id . kw-formals*] ...
|
||||||
maybe-defaults)
|
generics-opt ...)
|
||||||
([kw-formals* (arg* ...)
|
([generics-opt
|
||||||
|
(code:line #:defined-table defined-table-id)
|
||||||
|
(code:line #:defaults ([pred? method-impl ...] ...))]
|
||||||
|
[kw-formals* (arg* ...)
|
||||||
(arg* ...+ . rest-id)
|
(arg* ...+ . rest-id)
|
||||||
rest-id]
|
rest-id]
|
||||||
[arg* arg-id
|
[arg* arg-id
|
||||||
[arg-id]
|
[arg-id]
|
||||||
(code:line keyword arg-id)
|
(code:line keyword arg-id)
|
||||||
(code:line keyword [arg-id])]
|
(code:line keyword [arg-id])])]{
|
||||||
[maybe-defaults (code:line)
|
|
||||||
(code:line #:defaults ([pred?
|
|
||||||
method-impl ...]
|
|
||||||
...))])]{
|
|
||||||
|
|
||||||
Defines
|
Defines
|
||||||
|
|
||||||
|
@ -59,7 +58,11 @@ by-position argument that is @racket[free-identifier=?] to
|
||||||
@racket[id]. That argument is used in the generic definition to
|
@racket[id]. That argument is used in the generic definition to
|
||||||
locate the specialization.
|
locate the specialization.
|
||||||
|
|
||||||
When @racket[defined-table-id] is provided, it is defined as a
|
Keyword options to @racket[define-generics] may be provided both before and
|
||||||
|
after the list of methods, but not in the middle.
|
||||||
|
|
||||||
|
The @racket[#:defined-table] option may be provided at most once.
|
||||||
|
When it is provided, @racket[defined-table-id] is defined as a
|
||||||
procedure that takes an instance of the generics and returns an
|
procedure that takes an instance of the generics and returns an
|
||||||
immutable @tech{hash table} that maps symbols corresponding to method
|
immutable @tech{hash table} that maps symbols corresponding to method
|
||||||
names to booleans representing whether or not that method is
|
names to booleans representing whether or not that method is
|
||||||
|
@ -67,7 +70,8 @@ implemented by the instance. This table is intended for use by
|
||||||
higher-level APIs to adapt their behavior depending on method
|
higher-level APIs to adapt their behavior depending on method
|
||||||
availability.
|
availability.
|
||||||
|
|
||||||
When @racket[maybe-defaults] is provided, each generic function
|
The @racket[#:defaults] option may be provided at most once.
|
||||||
|
When it is provided, each generic function
|
||||||
uses @racket[pred?]s to dispatch to the given default implementations,
|
uses @racket[pred?]s to dispatch to the given default implementations,
|
||||||
@racket[method-impl]s, if dispatching to the generic method table fails.
|
@racket[method-impl]s, if dispatching to the generic method table fails.
|
||||||
The syntax of the @racket[method-impl]s is the same as the methods
|
The syntax of the @racket[method-impl]s is the same as the methods
|
||||||
|
|
Loading…
Reference in New Issue
Block a user