Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Primitive API

jacius edited this page · 4 revisions

Introduction

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".

pob Record Type

%make-pob

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.

pob?

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.)

%pob-base / %pob-set-base!

Procedure: (%pob-base POB)
Procedure: (%pob-set-base! POB BASE)

Get or set the pob's base. These procedures are API stable.

%pob-props / %pob-set-props!

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.

%pob-methods / %pob-set-methods!

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.

%pob-prop-resolver / %pob-set-prop-resolver!

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.

%pob-method-resolver / %pob-set-method-resolver!

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.

Props

%has-prop?

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.

%prop

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.

%resolve-prop

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:

  1. The pob in which the prop was found, or #f if the prop was not found anywhere in the inheritance chain.
  2. 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.

%set-prop!

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.

%unset-prop!

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.

Methods

%has-method?

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.

%method

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.

%resolve-method

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:

  1. The pob in which the method was found, or #f if the method was not found anywhere in the inheritance chain.
  2. 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.

%set-method!

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.

%unset-method!

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.

Method Context

%method-context

%active-pob

%active-method-name

Super Methods

%super-context

%same-super-context?

%super-invoked-procs

%super-resolve-next-method

%start-super

%continue-super

%super

%super*

Something went wrong with that request. Please try again.