Outdated egg!
This is an egg for CHICKEN 4, the unsupported old release. You're almost certainly looking for the CHICKEN 5 version of this egg, if it exists.
If it does not exist, there may be equivalent functionality provided by another egg; have a look at the egg index. Otherwise, please consider porting this egg to the current version of CHICKEN.
coops-utils
- Outdated egg!
- coops-utils
- Documentation
- Extras
- Introspection
- Argument Conventions
- Usage
- instance-of?
- class?
- instance?
- primitive-instance?
- generic?
- method?
- class-precedence-list
- class-slots
- class-direct-supers
- class-direct-slots
- generic-anonymous?
- generic-name
- generic-specialized-arguments
- generic-primary-methods
- generic-before-methods
- generic-after-methods
- generic-around-methods
- method-specializers
- method-procedure
- TinyClos Introspection
- Usage
- Examples
- Requirements
- Bugs and Limitations
- Author
- Version history
- License
Documentation
Some coops stuff.
Extras
Miscellaneous coops extensions.
Argument Conventions
INSTANCE is a coops-instance.
SLOT is a symbol.
INITFORM is 'SLOT OBJECT.
Usage
(require-extension coops-extras)
slot@
The slot accessor recursion.
[syntax] (slot@ INSTANCE SLOT ...) --> *Returns the slot value of the N'th named slot from INSTANCE.
[syntax] (slot@ INSTANCE SLOT ... [= OBJECT])Sets the slot value of the N'th named slot of INSTANCE to OBJECT.
Example:
(use coops coops-extras) ;Needlessly complex for example (define-class <first> () (next)) (define-class <second> (<first>) ()) (define-class <third> (<second>) ()) (define 1st (make <first> 'next (make <second> 'next (make <third> 'next "the end")))) (slot@ 1st next next next) ;=> "the end" (slot@ 1st next next next = "still the end") (slot@ 1st next next next) ;=> "still the end"
(From '@' macro by Dan Muresan.)
make/copy
[procedure] (make/copy INSTANCE [INITFORM ...]) --> coops-instanceReturns a copy of the object INSTANCE except where an INITFORM overrides an existing SLOT value of the INSTANCE.
describe-object
[procedure] (describe-object INSTANCE [OUT (current-output-port)])Prints information about the INSTANCE to the output-port OUT.
describe-object is a generic-procedure specializing the first argument.
A more detailed print-object for use in a REPL.
describe-object-slot
[procedure] (describe-object-slot INSTANCE SLOT [NAME-MAXLEN 32 [OUT (current-output-port)]])Prints information about the INSTANCE's SLOT to the output-port OUT. Does not append a (newline).
NAME-MAXLEN is the maximum number of single-width characters in a slotname.
Introspection
Some TInyCLOS inspired property readers.
Argument Conventions
Provides predicates and read accessors for coops objects.
OBJECT is a Scheme object.
CLASS is a coops class.
GENERIC is a coops generic-procedure.
METHOD is a coops generic-procedure method. Do not apply any but the supplied API to instances of this type!
Usage
(require-extension coops-introspection)
instance-of?
[procedure] (instance-of? OBJECT CLASS) --> booleanIs OBJECT an instance of the CLASS>?
class?
[procedure] (class? OBJECT) --> booleanIs OBJECT an instance of the <standard-class>?
[procedure] (check-class LOC OBJ [ARGNAM]) --> *[procedure] (error-class LOC OBJ [ARGNAM])
instance?
[procedure] (instance? OBJECT) --> booleanIs OBJECT an instance of a basic class. Neither an instance of the <standard-class> or a primitive such as boolean or vector?
[procedure] (check-instance LOC OBJ [ARGNAM]) --> *[procedure] (error-instance LOC OBJ [ARGNAM])
primitive-instance?
[procedure] (primitive-instance? OBJECT) --> booleanIs OBJECT an instance of the <primitive-object> class?
generic?
[procedure] (generic? OBJECT) --> booleanSynonym for generic-procedure?.
[procedure] (check-generic LOC OBJ [ARGNAM]) --> *[procedure] (error-generic LOC OBJ [ARGNAM])
method?
[procedure] (method? OBJECT) --> booleanIs OBJECT a method of a generic-procedure?
"Note" that the current implementation of methods does not depend on the type system. This function only validates the form of the argument and can be fooled.
[procedure] (check-method LOC OBJ [ARGNAM]) --> *[procedure] (error-method LOC OBJ [ARGNAM])
class-precedence-list
[procedure] (class-precedence-list CLASS) --> (list-of class)Returns the superclasses of CLASS.
class-slots
[procedure] (class-slots CLASS) --> (list-of symbol)Returns the slot names of CLASS.
class-direct-supers
[procedure] (class-direct-supers CLASS) --> (list-of class)Returns the uninherited superclasses of CLASS.
class-direct-slots
[procedure] (class-direct-slots CLASS) --> (list-of symbol)Returns the uninherited slot names of CLASS.
generic-anonymous?
[procedure] (generic-anonymous? GENERIC) --> booleanIs GENERIC an unnamed generic-procedure.
generic-name
[procedure] (generic-name GENERIC) --> (union #f symbol)Returns the name of GENERIC. The name is #f for an anonymous generic procedure.
generic-specialized-arguments
[procedure] (generic-specialized-arguments GENERIC) --> (list-of symbol)The arguments that GENERIC is specialized upon.
generic-primary-methods
[procedure] (generic-primary-methods GENERIC) --> (list-of method)Returns the list of #:primary methods for GENERIC.
generic-before-methods
[procedure] (generic-before-methods GENERIC) --> (list-of method)Returns the list of #:before methods for GENERIC.
generic-after-methods
[procedure] (generic-after-methods GENERIC) --> (list-of method)Returns the list of #:after methods for GENERIC.
generic-around-methods
[procedure] (generic-around-methods GENERIC) --> (list-of method)Returns the list of #:around methods for GENERIC.
method-specializers
[procedure] (method-specializers METHOD) --> (list-of class)Returns the classes that specialize METHOD.
method-procedure
[procedure] (method-procedure METHOD) --> procedureReturns the procedure for METHOD.
TinyClos Introspection
TInyCLOS synonyms.
Usage
(require-extension coops-introspection-tinyclos)
class-cpl
[procedure] (class-cpl CLASS) --> (list-of class)See coops-introspection#coops-introspection#class-precedence-list.
class-supers
[procedure] (class-supers CLASS) --> (list-of class)See coops-introspection#class-precedence-list.
primitive?
[procedure] (primitive? OBJECT) --> booleanSee coops-introspection#primitive-instance?.
generic-methods
[procedure] (generic-methods GENERIC) --> (list-of method)See coops-introspection#generic-primary-methods.
Usage
(require-extension coops-utils)
Examples
(use coops coops-introspection) (define (print-methods generic) (for-each (lambda (m) (print (generic-name generic) " specialized by " (method-specializers m) " as " (method-procedure m))) (generic-primary-methods generic)) )
Requirements
extras srfi 1 srfi 13 coops type-checks
Bugs and Limitations
- The introspection API is brittle, especially the generics portion.
Suggested only for use during REPL development with coops.
Author
Version history
- 1.1.0
- Collect TinyCLOS synonyms in own module: coops-introspection-tinyclos; reexport by coops-utils DEPRECATED.
- 1.0.4
- Remove test, remove inlines.
- 1.0.3
- Add test, fix library requirement.
- 1.0.2
- Fix make/copy for objects with uninitialized slots, thanks to Sandra Snan
- 1.0.1
- Fix class-direct-supers and class-direct-slots, minor internal optimization.
- 1.0.0
- Release for coops 1.92
- 0.0.3
- * UNMAINTAINED *
- 0.0.2
- 0.0.1
License
Copyright (C) 2010-2017 Kon Lovett. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the Software), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED ASIS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.