-
Notifications
You must be signed in to change notification settings - Fork 0
Primitive API
This reference guide describes the primitive API, a collection of low-level procedures that are used to construct the high-level API that most users will use. All the procedures described here are available in the protolk-primitives module. The primitive API is useful for customizing Protolk. However, you should normally not use any of these methods directly in your application code, only in the definition of custom high-level abstractions.
Note: the primitive API is much less stable than the normal API, i.e. it is more likely to change between versions. You should consider these procedures subject to change unless the description of the a procedure explicitly says that it is "API stable".
Procedure: (%make-pob ...)
The low-level constructor for pobs. Do not use this procedure, ever. Instead, use the make-pob
procedure from the normal API, which wraps this procedure in a more API-stable interface.
Procedure: (pob? VALUE)
Returns #t
if VALUE is a pob, or #f
if it is some other type of value. This procedure is API stable. (In Protolk 0.5, this procedure is only available in the primitive API, but in the future it will also be available in the normal API.)
Procedure: (%pob-base POB)
Procedure: (%pob-set-base! POB BASE)
Get or set the pob's base. These procedures are API stable.
Procedure: (%pob-props POB)
Procedure: (%pob-set-props! POB PROPS-LIST)
Get or set the pob's props list. These procedures are not API stable, because the internal representation of the props list may change in the future. You should instead use the procedures described in the "Props" section, below.
Procedure: (%pob-methods POB)
Procedure: (%pob-set-methods! POB METHODS-LIST)
Get or set the pob's methods list. These procedures are not API stable, because the internal representation of the methods list may change in the future. You should instead use the procedures described in the "Methods" section, below.
Procedure: (%pob-prop-resolver POB)
Procedure: (%pob-set-prop-resolver! POB PROP-RESOLVER)
Get or set the pob's prop resolver. These procedures are API stable. See Advanced Customization for more information about prop and method resolvers.
Procedure: (%pob-method-resolver POB)
Procedure: (%pob-set-method-resolver! POB METHOD-RESOLVER)
Get or set the pob's method resolver. These procedures are API stable. See Advanced Customization for more information about prop and method resolvers.
Procedure (%has-prop? POB PROP-NAME)
Returns #t
if the given pob itself contains a prop with the given name, ignoring inheritance. Returns #f
if it does not.
Procedure: (%prop POB PROP-NAME #!optional DEFAULT)
Returns the value contained in the given pob for the given prop name, ignoring inheritance. If it does not contain a prop with that name, returns DEFAULT, which is #<unspecified>
by default.
Procedure: (%resolve-prop POB PROP-NAME #!optional DEFAULT)
Performs a prop look-up using the pob's prop-resolver to find the value of the given prop name, which may be inherited from another pob. Returns a cons cell containing:
- The pob in which the prop was found, or
#f
if the prop was not found anywhere in the inheritance chain. - The value of the prop that was found, or
DEFAULT
(which is#<unspecified>
by default) if the prop was not found anywhere in the inheritance chain.
Procedure: (%set-prop! POB PROP-NAME VALUE)
Sets the value of the prop in the pob. If the pob already contains a prop with that name, the value is replaced. If the pob does not contain a prop with that name, it is created with the given value.
Procedure: (%unset-prop! POB PROP-NAME)
Removes the prop with the given name from the pob, it in contains such a prop. This allows the pob to inherit the prop from its ancestors, if any. If the pob does not contain such a prop, this procedure has no effect.
Procedure (%has-method? POB METHOD-NAME)
Returns #t
if the given pob itself contains a method with the given name, ignoring inheritance. Returns #f
if it does not.
Procedure: (%method POB METHOD-NAME #!optional DEFAULT)
Returns the procedure contained in the given pob for the given method name, ignoring inheritance. If it does not contain a method with that name, returns DEFAULT, which is #<unspecified>
by default.
Procedure: (%resolve-method POB METHOD-NAME #!optional DEFAULT)
Performs a method look-up using the pob's method-resolver to find the procedure for the given method name, which may be inherited from another pob. Returns a cons cell containing:
- The pob in which the method was found, or
#f
if the method was not found anywhere in the inheritance chain. - The procedure for the method that was found, or
DEFAULT
(which is#<unspecified>
by default) if the method was not found anywhere in the inheritance chain.
Procedure: (%set-method! POB METHOD-NAME PROCEDURE)
Sets the procedure for the method in the pob. If the pob already contains a method with that name, the value is replaced. If the pob does not contain a method with that name, it is created with the given procedure.
Procedure: (%unset-method! POB METHOD-NAME)
Removes the method with the given name from the pob, it in contains such a method. This allows the pob to inherit the method from its ancestors, if any. If the pob does not contain such a method, this procedure has no effect.