The policy-cond Reference Manual

This is the policy-cond Reference Manual, generated automatically by Declt version 4.0 beta 2 "William Riker" on Thu Feb 15 07:10:01 2024 GMT+0.

Table of Contents


1 Introduction


2 Systems

The main system appears first, followed by any subsystem dependency.


2.1 policy-cond

Tools to insert code based on compiler policy.

Maintainer

Robert Smith <>

Author

Robert Smith <>

License

BSD 3-clause (See LICENSE)

Long Description

POLICY-COND provides tools to insert and execute code based on one’s compiler’s OPTIMIZE policy. It also contains a contract-like notion of ’expectations’, which allow dynamic checking or inclusion of various things to happen depending on compiler policy.

Dependencies
  • sb-cltl2 (system)., for feature :sbcl
  • cl-environments (system)., for feature (:not (:or :sbcl :lispworks :cmucl :ccl :allegro))
Source

policy-cond.asd.

Child Components

3 Files

Files are sorted by type and then listed depth-first from the systems components trees.


3.1 Lisp


3.1.1 policy-cond/policy-cond.asd

Source

policy-cond.asd.

Parent Component

policy-cond (system).

ASDF Systems

policy-cond.


3.1.2 policy-cond/package.lisp

Dependency

license.txt (file).

Source

policy-cond.asd.

Parent Component

policy-cond (system).

Packages

3.1.3 policy-cond/policy-cond.lisp

Dependency

package.lisp (file).

Source

policy-cond.asd.

Parent Component

policy-cond (system).

Public Interface
Internals

policy (macro).


3.1.4 policy-cond/expectations.lisp

Dependency

policy-cond.lisp (file).

Source

policy-cond.asd.

Parent Component

policy-cond (system).

Public Interface

with-expectations (macro).


3.1.5 policy-cond/policy.lisp

Dependency

expectations.lisp (file).

Source

policy-cond.asd.

Parent Component

policy-cond (system).

Public Interface

if (macro).


3.2 Static


3.2.1 policy-cond/LICENSE.txt

Source

policy-cond.asd.

Parent Component

policy-cond (system).


4 Packages

Packages are listed by definition order.


4.1 policy

Source

package.lisp.

Use List

common-lisp.

Public Interface

if (macro).


4.2 policy-cond

Source

package.lisp.

Use List

common-lisp.

Public Interface
Internals

policy (macro).


5 Definitions

Definitions are sorted by export status, category, package, and then by lexicographic order.


5.1 Public Interface


5.1.1 Macros

Macro: if (form)

Intended to be used with read macros. FORM should be a policy expression as described in POLICY-COND:POLICY-COND. For example,

#+#.(policy:if (> speed safety)) EXPRESSION

Package

policy.

Source

policy.lisp.

Macro: policy-cond (&body cases)

Like COND, except each clause predicate is a policy expression. A policy expression is a boolean expression using optimize declaration qualities such as SPEED, SAFETY, DEBUG, COMPILATION-SPEED, etc. as if they’re lexically bound to their actual value.

The result of POLICY-COND will be the first clause whose policy expression is satisfied. This is computed at compile time based off the current compiler policy.

Package

policy-cond.

Source

policy-cond.lisp.

Macro: policy-if (expr then else)

If the policy expression EXPR is true, then expand into THEN, otherwise into ELSE. The policy expression is as described in POLICY-COND.

Package

policy-cond.

Source

policy-cond.lisp.

Macro: with-expectations (policy (&rest expectations) &body body)

Execute BODY with expectations laid out by the clauses EXPECTATIONS when the policy expression POLICY holds true. When POLICY does not hold true, then EXPECTATIONS will be explicitly checked at runtime.

EXPECTATIONS should be lists of one of the following forms.

Type Expectation: (TYPE <type> <vars-or-exprs>...)

Assert that the variables and expressions <vars-or-exprs> should
have the type <type>. If the POLICY is met, then declarations
will be made for the variables only.

Return Type Expectation: (RETURNS [<type>*])

Assert that the result of a form obeys a certain type. Multiple
types indicate multiple values are returned. If the POLICY is
met, then the assertion will be elided at runtime.

Assertion Expectation: (ASSERTION <assertion> [(place*) [datum-form argument-form*]])

Assert that the assertion <assertion> should be true. If the
POLICY is met, then the assertion will be elided at runtime.

Conditional Expectation: (OR-ELSE <predicate> <resulting action>)

Check that the predicate <predicate> is true, or else perform
<resulting action>. If the POLICY is met, elide the check and
action. This clause is principally used for having special
conditions get raised.

Inline Expectation: (INLINE [<symbol>*])

Inline the functions designated by the symbols <symbol> if POLICY
is met.

Package

policy-cond.

Source

expectations.lisp.

Macro: with-policy (policy &body body)

Execute the body BODY with the global optimize policy set to POLICY. Once BODY has finished executing, restore the compiler policy to its original state.

For local declarations, use LOCALLY.

Package

policy-cond.

Source

policy-cond.lisp.


5.1.2 Ordinary functions

Function: declaration-information (symbol &optional env)

Get the declaration information for the environment ENV.

Package

policy-cond.

Source

policy-cond.lisp.


5.2 Internals


5.2.1 Macros

Macro: policy (expr env)
Package

policy-cond.

Source

policy-cond.lisp.


Appendix A Indexes


A.1 Concepts


A.3 Variables