The cl-form-types Reference Manual

Next: , Previous: , Up: (dir)   [Contents][Index]

The cl-form-types Reference Manual

This is the cl-form-types Reference Manual, version 0.3.1, generated automatically by Declt version 4.0 beta 2 "William Riker" on Thu Sep 15 03:45:29 2022 GMT+0.

Table of Contents


1 Introduction

CL-FORM-TYPES

This library provides functions for determining the value types of Common Lisp forms, based on type information contained in the environment.

In order for this library to work the values types of variables and return types of functions have to be declared.

Macros and symbol-macros are fully expanded and all special forms, except CATCH, are supported.

This library depends on cl-environments in order to extract information from the environment using the CLTL2 API. Check the library's documentation for details on how to ensure that information contained in the environment can be retrieved, across all implementations.

Package CL-FORM-TYPES

FORM-TYPE

Function FORM-TYPE FORM ENV &KEY CONSTANT-EQL-TYPES EXPAND-COMPILER-MACROS

Determine the type of a form in a given environment.

Returns the type specifier of the value to which FORM evaluates. If FORM evaluates to multiple values a (VALUES ...) type is returned. If the type of FORM could not be determined T is returned.

NTH-FORM-TYPE

Function NTH-FORM-TYPE FORM ENV &OPTIONAL (N 0) CONSTANT-EQL-TYPES EXPAND-COMPILER-MACROS

Determine the type of the nth return value of a form.

Returns the type specifier of the Nth value returned by FORM. If FORM returns less values than N, NIL is returned.

NTH-VALUE-TYPE

Function NTH-VALUE-TYPE TYPE &OPTIONAL (N 0)

Extract the type of the nth return value from a VALUES type specifier.

Returns the nth value type or NIL if N is greater than the number values in the type specifier.

FORM-TYPES

Function FORM-TYPES FORMS ENV &KEY CONSTANT-EQL-TYPES EXPAND-COMPILER-MACROS

Determine the type of each form in a list.

Returns a list where each element is the type specifier of the corresponding form in FORMS.

CUSTOM-FORM-TYPE

Generic Function CUSTOM-FORM-TYPE OPERATOR ARGUMENTS ENV

Generic function for determining the type of non-standard special forms and function calls.

This function is not intended to be called directly but is intended to be extended with methods to add custom type deduction logic for function calls and non-standard special forms.

NOTE: The environment argument is not necessarily a native environment object, but may be an augmented environment object. Therefore it should not be passed directly to built in functions which expect an environment object but rather the equivalent functions from the CL-ENVIRONMENTS-CL package should be used, see https://alex-gutev.github.io/cl-environments/#wrapper_functions.

Returns the value type of the form (OPERATOR . ARGUMENTS), or T if it's type could not be determined.

*HANDLE-SB-LVARS*

Variable: *HANDLE-SB-LVARS*

Flag for whether SBCL's SB-C::LVAR structures should be recognized.

If true and an SB-C::LVAR structure is encountered as a constant, the type returned is the derived type of the LVAR.

If NIL SB-C::LVAR's are treated as literal constant objects, and the type returned is either an EQL type specifier or LVAR depending on the value of the CONSTANT-EQL-TYPES argument to FORM-TYPE / NTH-FORM-TYPE.

NOTE: The value of this variable only has an effect on SBCL.

MALFORMED-FORM-ERROR

Condition MALFORMED-FORM-ERROR (PROGRAM-ERROR)

Condition signalled when a malformed form is passed to one of the FORM-TYPE functions.

NOTE: Inherits from the PROGRAM-ERROR condition which may also be signalled. Thus if you want to handle all conditions which may be signalled by FORM-TYPE, handle the PROGRAM-ERROR condition.

Slots:

UNKNOWN-SPECIAL-OPERATOR

Condition UNKNOWN-SPECIAL-OPERATOR (PROGRAM-ERROR)

Condition signalled when an unknown special operator is encountered.

NOTE: This indicates the use of a non-standard, implementation-specific, special operator. This condition will never be raised for a standard CL operator.

Slots:

RETURN-DEFAULT-TYPE

Function RETURN-DEFAULT-TYPE &OPTIONAL (TYPE T)

Invoke the RETURN-DEFAULT-TYPE restart.

This restart, for a MALFORMED-FORM-ERROR condition, returns the type TYPE as the form type for the malformed form.

Code Walker

The package CL-FORM-TYPES.WALKER exposes the (mostly) portable code-walker used by the FORM-TYPE functions.

WALK-FORM

Function: WALK-FORM FN FORM ENV &KEY (RESULT-TYPE 'LIST)

Apply a function on a form and each of its subforms, and return the resulting form.

Returns the new transformed form, if RESULT-TYPE is LIST.

Type Deduction Logic

This section contains notes on how types are deduced for various form types.

LAMBDA Expressions

This refers to lambda expressions occurring within FUNCTION forms and as the operator (the CAR) of an expression.

In FUNCTION Form

When the argument to a FUNCTION form is a LAMBDA expression, a list-form FUNCTION type is returned with argument and return value types.

The number of arguments is deduced from the expression's lambda-list, with the types deduced from type declarations immediately within the expression body. If the type cannot be determined for an argument * is placed in its position within the function type specifier.

The return value type is deduced from the return value type of the last form in the expression body. If this cannot be determined, T is placed as the return value type in the function type specifier.

Examples:


(form-type
  '#'(lambda (x &optional y &key z)
       (pprint y)
       (pprint z)
       x)
   nil)

;; Returns

(function (* &optional * &key (:z *)) t)

A more detailed type is returned when the types of the argument variables are declared:

(form-type
  '#'(lambda (x &optional y &key z)
       (declare (type number x)
                (type symbol y)
                (type string z))

       (pprint y)
       (pprint z)
       x)
   NIL)

;; Returns

(function (number &optional symbol &key (:z string)) number)

As Form Operator

When a lambda expression appears as the operator in a form, the type of the lambda expression is deduced and the return type of the FUNCTION type specifier, is returned as the type of the form.

BLOCK forms

The type of a BLOCK form is deduced not only by the type of the last form in its body but also by analysing the forms within the body of the BLOCK form and combining the types of the result forms in each RETURN-FROM form, that has a block name that matches the name of the BLOCK form.

RETURN-FROM forms which appear within a lexically defined function, by FLET or LABELS, are only included in the analysis if that lexically defined function is called or referenced by a FUNCTION form.

Examples:

(form-type
 '(block blk
    (do-something 1)
    (do-something 2)
    (the number (+ x y)))

  NIL)

;; Returns

number

With a RETURN-FROM form:

(form-type
 '(block blk
    (when (evenp x)
       (return-from blk 'even))

    (the number (+ x y)))

  NIL)

;; Returns

(or number (eql even))

With a RETURN-FROM inside a lexically defined function which is not called:

(form-type
 '(block blk
    (flet ((test (x)
             (when (evenp x)
               (return-from blk 'even))
             x))

     (the number (+ x y))))

  NIL)

;; Returns

number

NOTE: The type of the RETURN-FROM form inside the TEST function is not included since the function is never called.

With a RETURN-FROM inside a lexically defined function which is referenced:

(form-type
 '(block blk
    (flet ((test (x)
             (when (evenp x)
               (return-from blk 'even))
             x))

     (the list (mapcar #'test numbers))))

  NIL)

;; Returns

(or list (eql even))

NOTE: The type of the RETURN-FROM form inside the TEST function is included despite the function never being called since the function is referenced with (FUNCTION TEST) (#'TEST), thus it could potentially be called.

CATCH forms

No type deduction logic is performed on CATCH forms as of yet, due to the difficulty of the problem posed by dynamic tag names. Thus, FORM-TYPE simply returns T when given a CATCH form.


2 Systems

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


Previous: , Up: Systems   [Contents][Index]

2.1 cl-form-types

Library for determining types of Common Lisp forms.

Author

Alexander Gutev

License

MIT

Version

0.3.1

Dependencies
  • cl-environments (system).
  • agutil (system).
  • alexandria (system).
  • anaphora (system).
  • optima (system).
  • arrows (system).
  • introspect-environment (system).
Source

cl-form-types.asd.

Child Component

src (module).


3 Modules

Modules are listed depth-first from the system components tree.


Previous: , Up: Modules   [Contents][Index]

3.1 cl-form-types/src

Source

cl-form-types.asd.

Parent Component

cl-form-types (system).

Child Components

4 Files

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


Previous: , Up: Files   [Contents][Index]

4.1 Lisp


Next: , Previous: , Up: Lisp   [Contents][Index]

4.1.1 cl-form-types/cl-form-types.asd

Source

cl-form-types.asd.

Parent Component

cl-form-types (system).

ASDF Systems

cl-form-types.


4.1.2 cl-form-types/src/package.lisp

Source

cl-form-types.asd.

Parent Component

src (module).

Packages

4.1.3 cl-form-types/src/form-types.lisp

Dependency

package.lisp (file).

Source

cl-form-types.asd.

Parent Component

src (module).

Public Interface
Internals

4.1.4 cl-form-types/src/walker.lisp

Dependency

form-types.lisp (file).

Source

cl-form-types.asd.

Parent Component

src (module).

Internals

4.1.5 cl-form-types/src/block-types.lisp

Dependency

walker.lisp (file).

Source

cl-form-types.asd.

Parent Component

src (module).

Internals

4.1.6 cl-form-types/src/cl-functions.lisp

Dependency

block-types.lisp (file).

Source

cl-form-types.asd.

Parent Component

src (module).

Public Interface
Internals

5 Packages

Packages are listed by definition order.


Next: , Previous: , Up: Packages   [Contents][Index]

5.1 cl-form-types

Exports utilities for determining the types of common lisp forms, based on information found in the environment.

Source

package.lisp.

Use List
  • agutil.
  • alexandria.
  • anaphora.
  • arrows.
  • cl-environments-cl.
  • optima.
Public Interface
Internals

Previous: , Up: Packages   [Contents][Index]

5.2 cl-form-types.walker

Export code-walker used internally for type analysis.

Source

package.lisp.


6 Definitions

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


Next: , Previous: , Up: Definitions   [Contents][Index]

6.1 Public Interface


6.1.1 Special variables

Special Variable: *handle-sb-lvars*

Flag for whether SBCL ‘SB-C::LVAR’ structures should be recognized.

If true the type of an LVAR is returned if encountered as a constant.

If NIL LVARS as treated as literal constant and an EQL type or LVAR is returned, depending on the value of*CONSTANT-EQL-TYPES*.

Package

cl-form-types.

Source

form-types.lisp.


6.1.2 Ordinary functions

Function: form-type (form env &key expand-compiler-macros constant-eql-types)

Determines the type of a form in an environment.

FORM is the form of which to determine the type.

ENV is the environment in which the form occurs.

:CONSTANT-EQL-TYPES is a flag for whether EQL type specifiers should be returned for all constant forms. If NIL EQL types specifiers are only returned for constants which are comparable with EQL, that is NUMBERS, CHARACTERS and SYMBOLS.

:EXPAND-COMPILER-MACROS is a flag, which if true, compiler-macros are expanded prior to determining the type of FORM or a subform of it.

Returns the type of the value to which FORM evaluates to. Returns a VALUES type if FORM evaluates to multiple values. Returns T if the type could not be determined.

Package

cl-form-types.

Source

form-types.lisp.

Function: form-types (forms env &key constant-eql-types expand-compiler-macros)

Determines the type of each form in FORMS.

FORMS is a list of forms.

ENV is the environment in which the forms occur.

:CONSTANT-EQL-TYPES if a flag for whether EQL type specifiers should be returned for all constant forms. If NIL EQL types specifiers are only returned for constants which are comparable with EQL, that is NUMBERS, CHARACTERS and SYMBOLS.

:EXPAND-COMPILER-MACROS is a flag, which if true, compiler-macros are expanded prior to determining the type of FORM or a subform of it.

Returns a list where each element is the type to which the corresponding form in FORMS evaluates to

Package

cl-form-types.

Source

form-types.lisp.

Function: nth-form-type (form env &optional n *constant-eql-types* *expand-compiler-macros*)

Determines the type of the N’th value of a form.

The difference between this and FORM-TYPE is that, FORM-TYPE returns a VALUES type if the form evaluates to multiple values, whereas this function returns only the type of the N’th value.

FORM is the form of which to determine the type.

ENV is the environment in which the form occurs.

N is the index of the return value of which to return the type.

CONSTANT-EQL-TYPES if a flag for whether EQL type specifiers should be returned for all constant forms. If NIL EQL types specifiers are only returned for constants which are comparable with EQL, that is NUMBERS, CHARACTERS and SYMBOLS.

EXPAND-COMPILER-MACROS is a flag, which if true, compiler-macros are expanded prior to determining the type of FORM or a subform of it.

Returns the type of the N’th return value of FORM. If there is no type information for the N’th value, that is FORM does not evaluate to multiple values or evaluates to less values than N, NIL is returned.

Package

cl-form-types.

Source

form-types.lisp.

Function: nth-value-type (type &optional n)

Extract the type of the N’th return value.

If TYPE is a VALUES type specifier, returns the type of the N’th value, otherwise TYPE is treated as a VALUES type specifier with a single value type.

TYPE is the type specifier.

N is the index of the return value of which to return the type.

Returns the N’th value type or NIL if there is no information about the N’th return value.

Package

cl-form-types.

Source

form-types.lisp.

Function: return-default-type (&optional type)

Invoke the RETURN-DEFAULT-TYPE restart for ‘MALFORMED-FORM-ERROR’ conditions.

This restart returns the type TYPE for the type of the malformed form.

Package

cl-form-types.

Source

form-types.lisp.


6.1.3 Generic functions

Generic Function: custom-form-type (operator arguments env)

Method for determining form types of custom forms.

This is useful for adding special type deduction logic for your own functions, or for non-standard special forms.

OPERATOR is the form operator.

ARGUMENTS is the list of argument forms.

ENV is the environment in which the form is found. This might not be a native environment but an augmented environment from cl-environments.

Package

cl-form-types.

Source

form-types.lisp.

Methods
Method: custom-form-type ((first (eql coerce)) arguments env)
Source

cl-functions.lisp.

Method: custom-form-type ((first (eql values)) args env)
Source

cl-functions.lisp.

Method: custom-form-type ((first (eql row-major-aref)) form env)
Source

cl-functions.lisp.

Method: custom-form-type ((first (eql aref)) form env)
Source

cl-functions.lisp.

Method: custom-form-type ((first (eql make-string)) form env)
Source

cl-functions.lisp.

Method: custom-form-type ((first (eql make-array)) form env)
Source

cl-functions.lisp.

Method: custom-form-type ((first (eql make-instance)) form env)
Source

cl-functions.lisp.

Method: custom-form-type (operator arguments env)

6.1.4 Conditions

Condition: malformed-form-error

Condition signalling that a form passed to FORM-TYPE is malformed.

Package

cl-form-types.

Source

form-types.lisp.

Direct superclasses

program-error.

Direct methods

form.

Direct slots
Slot: form
Initargs

:form

Readers

form.

Writers

This slot is read-only.

Condition: unknown-special-operator

Condition representing that an special operator was encountered which this library does not know how to process.

Package

cl-form-types.

Source

form-types.lisp.

Direct superclasses

program-error.

Direct methods
Direct slots
Slot: operator
Initargs

:operator

Readers

operator.

Writers

This slot is read-only.

Slot: operands
Initargs

:operands

Readers

operands.

Writers

This slot is read-only.


6.2 Internals


Next: , Previous: , Up: Internals   [Contents][Index]

6.2.1 Constants

Constant: +cl-special-forms+

List of standard common lisp special forms

Package

cl-form-types.

Source

walker.lisp.


Next: , Previous: , Up: Internals   [Contents][Index]

6.2.2 Special variables

Special Variable: *block-name*

The name of the BLOCK of which the type is currently being determined.

Package

cl-form-types.

Source

block-types.lisp.

Special Variable: *block-types*

List containing the list of value types returned by the current BLOCK form.

Package

cl-form-types.

Source

block-types.lisp.

Special Variable: *constant-eql-types*

Flag for whether EQL type specifiers should be returned for all constant forms.

If NIL EQL types are only returned if a form evaluates to a
constant which is comparable with EQL, such as NUMBERS, CHARACTERS
and SYMBOLS. If T, an EQL type is returned for every form which evaluates to a constant value.

Package

cl-form-types.

Source

form-types.lisp.

Special Variable: *expand-compiler-macros*

Flag for whether compiler-macros should be expanded prior to determining form types.

Package

cl-form-types.

Source

form-types.lisp.

Special Variable: *in-block*

Flag for whether RETURN-FROM forms to the block name *BLOCK-NAME* are treated as returning from the block, of which the type is currently being determined, (true) or they are treated as returning from a block nested in it (false).

Package

cl-form-types.

Source

block-types.lisp.

Special Variable: *local-fns*

Association list of the types of values returned from the current block by RETURN-FROM forms located within functions defined locally within the block.

Package

cl-form-types.

Source

block-types.lisp.

Special Variable: *use-local-declared-types*

Flag for whether the declared types, in the local environment, should be used.

If NIL the declared types in the global NIL environment are used.

The purpose of this is to support LOAD-TIME-VALUE, in which the
form is macroexpanded in the local environment but is actually evaluated in the global environment, therefore it does not have
access to local variables.

Package

cl-form-types.

Source

form-types.lisp.

Special Variable: *walk-fn*

The walk function to call on each form.

Package

cl-form-types.

Source

walker.lisp.

Special Variable: *walk-result-type*

The type of result which should be returned by the walk function.

Package

cl-form-types.

Source

walker.lisp.


6.2.3 Macros

Macro: lm (&rest var-body)
Package

cl-form-types.

Source

cl-functions.lisp.

Macro: match-form (form &body clauses)

Like MATCH but with a default clause which signals a ‘MALFORMED-FORM-ERROR’ condition.

Package

cl-form-types.

Source

form-types.lisp.

Macro: with-default-type-restart (&body forms)

Evaluate forms in a RESTART-CASE with the RETURN-DEFAULT-TYPE restart established.

Package

cl-form-types.

Source

form-types.lisp.

Macro: with-result ((result form) &body forms)

Evaluate FORMS returning the correct result type per *WALK-RESULT-TYPE*

RESULT is a symbol naming the symbol-macro introduced to FORMS, by SYMBOL-MACROLET, which expands to FORM.

If *WALK-RESULT-TYPE* is LIST, FORMS are evaluated in an implicit PROGN. These may reference the binding to the symbol-macro named by RESULT.

If *WALK-RESULT-TYPE* is NIL, FORM is returned directly.

Package

cl-form-types.

Source

walker.lisp.


Next: , Previous: , Up: Internals   [Contents][Index]

6.2.4 Ordinary functions

Function: block-type-walk-form (form env)

Walk a subform of a BLOCK form and extract the value types returned from the block by RETURN-FROM.

Package

cl-form-types.

Source

block-types.lisp.

Function: block-type-walk-local-fn (def env)

Extract RETURN-FROM value types from a local named function definition.

DEF is the list containing the function definition, with the first element being the function name.

ENV is the environment in which the form is found.

Returns the list of value types which may be returned when the function is called.

Package

cl-form-types.

Source

block-types.lisp.

Function: combine-values-types (combinator type1 type2 &optional default-type)

Combine two type specifier using a combinator keyword.

If both types are a VALUES types, each corresponding value type is combined into a list with the first element being COMBINATOR and the next two elements being the type specifiers. If only one of the types is a VALUES type, the other is treated as a VALUES type with one value type.

If neither types are values types the result ‘(,COMBINATOR ,TYPE1 ,TYPE2) is returned.

COMBINATOR is the symbol naming the combinator.

TYPES1 and TYPES2 are the types to combine.

DEFAULT-TYPE is the type used when combining the values type specifier with more value types. When the all the value types in the specifier with less values, are combined with value types from the specifier with more values, the remaining extra values are combined with DEFAULT-TYPE, unless the shorter values type specifier also specifies a &REST type.

Returns the combined type specifier.

Package

cl-form-types.

Source

form-types.lisp.

Function: constant-form-value (form env)

Determine the value of a constant form.

FORM is the form of which to determine the value. Must be a form for which CONSTANTP returns true.

ENV is the environment in which FORM is found.

Package

cl-form-types.

Source

form-types.lisp.

Function: constant-type (value)

Return the type specifier of a constant value.

If the value is a CHARACTER, NUMBER or SYMBOL an EQL type specifier is returned. Otherwise the type specifier returned by TYPE-OF is returned.

VALUE is the constant value.

Package

cl-form-types.

Source

form-types.lisp.

Function: copy-values-type-spec (instance)
Package

cl-form-types.

Source

form-types.lisp.

Function: expand-compiler-macros (operator arguments env)

Expand compiler-macros in a function call expression.

Only expands compiler macros if *EXPAND-COMPILER-MACROS is set.

OPERATOR is the form operator.

ARGUMENTS is the argument list of the form.

ENV is the environment in which the form is found.

Returns the compiler-macro-expanded form or NIL if there is no compiler-macro for OPERATOR.

Package

cl-form-types.

Source

form-types.lisp.

Function: expand-form-type (form env)

Determines the type of a form, in an environment, after macroexpand.

FORM is the form of which to determine the type.

ENV is the environment in which the form occurs.

Package

cl-form-types.

Source

form-types.lisp.

Function: extract-return-from-types (name form env)

Extract the list of value types returned by a BLOCK form.

*BLOCK-NAME* is the label naming the block.

FORM is a PROGN form representing the block body.

ENV is the environment in which the BLOCK form is contained.

Returns the list of value types which may be returned from the BLOCK form by an explicit RETURN-FROM form.

Package

cl-form-types.

Source

block-types.lisp.

Function: flet-form-type (operands env)

Determine the type of a FLET/LABELS form.

OPERANDS is the list of operands to the form.

ENV is the environment in which the form is found.

Package

cl-form-types.

Source

form-types.lisp.

Function: form-type% (form env)
Package

cl-form-types.

Source

form-types.lisp.

Function: lambda-expression-type (lambda-list body env)

Determine the function type of a lambda expression.

LAMBDA-LIST is the lambda-list of the lambda expression.

BODY is the body of the lambda expression (the remainder of the expression following the lambda-list).

ENV is the environment in which the form containing the lambda expression is found.

Returns a (FUNCTION ...) specifier.

Package

cl-form-types.

Source

form-types.lisp.

Function: let-form-type (operands env)

Determine the type of a LET/LET* form.

OPERANDS is the list of operands to the form.

ENV is the environment in which the form is found.

Package

cl-form-types.

Source

form-types.lisp.

Function: list-form-type (operator arguments env)

Determine the type of a list form.

OPERATOR is the list form operator.

ARGUMENTS is the list of arguments following the operator.

ENV is the environment in which the form occurs.

Package

cl-form-types.

Source

form-types.lisp.

Function: local-function-type (name)
Package

cl-form-types.

Source

block-types.lisp.

Function: local-function-types (names functions env)

Determine the types of the RETURN-FROM forms in lexical functions.

NAMES is the list of the function names.

FUNCTIONS is the list of the function definitions as they appear in the FLET or LABELS form.

ENV is the environment in which the lexical function definitions occur.

Package

cl-form-types.

Source

block-types.lisp.

Function: make-values-type-spec (&key types optional-start rest-p rest-type allow-other-keys other)
Package

cl-form-types.

Source

form-types.lisp.

Function: maybe-constant-form-value (form env &key default)
Package

cl-form-types.

Source

cl-functions.lisp.

Function: parse-values-type (spec)

Parse a VALUES type specifier into its components.

SPEC is the VALUES type specifier list following the VALUES keyword.

Returns a ‘VALUES-TYPE-SPEC’ object.

Package

cl-form-types.

Source

form-types.lisp.

Function: subst-local-function-types (ftypes)

Substitute (CALL ...) types with actual types returned by the function.

In the types of the RETURN-FROM forms, located within a function, types which reference the types of the RETURN-FROM forms in another function ‘(CALL ...)‘ are replaced with the actual list of the types of the RETURN-FROM forms in that function.

FTYPES is an association list with each entry of the form (FN
. TYPES) where FN is the function name and TYPES is the list of type specifiers.

Returns the association list with the new RETURN-FORM form type lists.

Package

cl-form-types.

Source

block-types.lisp.

Reader: values-type-spec-allow-other-keys (instance)
Writer: (setf values-type-spec-allow-other-keys) (instance)
Package

cl-form-types.

Source

form-types.lisp.

Target Slot

allow-other-keys.

Reader: values-type-spec-optional-start (instance)
Writer: (setf values-type-spec-optional-start) (instance)
Package

cl-form-types.

Source

form-types.lisp.

Target Slot

optional-start.

Reader: values-type-spec-other (instance)
Writer: (setf values-type-spec-other) (instance)
Package

cl-form-types.

Source

form-types.lisp.

Target Slot

other.

Function: values-type-spec-p (object)
Package

cl-form-types.

Source

form-types.lisp.

Reader: values-type-spec-rest-p (instance)
Writer: (setf values-type-spec-rest-p) (instance)
Package

cl-form-types.

Source

form-types.lisp.

Target Slot

rest-p.

Reader: values-type-spec-rest-type (instance)
Writer: (setf values-type-spec-rest-type) (instance)
Package

cl-form-types.

Source

form-types.lisp.

Target Slot

rest-type.

Reader: values-type-spec-types (instance)
Writer: (setf values-type-spec-types) (instance)
Package

cl-form-types.

Source

form-types.lisp.

Target Slot

types.

Function: variable-type (variable env)

Determine the type of a variable.

VARIABLE is the symbol naming the variable. This may name a constant as well.

ENV is the environment in which the variable is found.

Package

cl-form-types.

Source

form-types.lisp.

Function: walk-body (body env &key variable function symbol-macro macro documentation)

Walk the body of a form which modifies the lexical environment.

BODY is the list containing the form’s body. The first element of the list may be a DECLARE expression.

ENV is the environment of the form body. This excludes declaration information in DECLARE expressions located in BODY.

DOCUMENTATION is a flag for whether BODY may contain documentation strings (true).

The remaining keyword arguments are additional arguments to pass to AUGMENT-ENVIRONMENT on environment ENV.

Returns the new form body.

Package

cl-form-types.

Source

walker.lisp.

Function: walk-fn-def (def env)

Walk a function definition.

DEF the function definition starting from the LAMBDA-LIST.

ENV the environment in which to walk the definition.

Package

cl-form-types.

Source

walker.lisp.

Function: walk-form (fn form env &key result-type)

Apply a function on each subform in a form.

FN:

A function of two arguments that is called for each subform in FORM, with two arguments: the form and the environment in which it occurs.

It should return the following return values:

1. The new form. The subforms of this form are walked and it is substituted in place of the old form, in the result returned by WALK-FORM.

2. A Boolean flag. If true the subforms of the form returned in (1) are not walked, and it is substituted as it is in the result. Otherwise the subforms are walked.

FORM:

The form to walk. The function is first applied on FORM itself, then on its subforms.

ENV:

The environment in which FORM is found.

RESULT-TYPE:

A symbol indicating the type of result that should be returned from WALK-FORM:

LIST - The new form, built out of the subforms returned by FN, is returned. This is the default.

NIL - No new form is constructed, meaning the return value of FN is used only to determine which forms to walk next.

Returns the new transformed form, if RESULT-TYPE is LIST.

Package

cl-form-types.

Source

walker.lisp.

Function: walk-form% (form env)

Internal code-walker function, that calls the current walk function (*WALK-FN*).

Package

cl-form-types.

Source

walker.lisp.

Function: walk-forms (forms env)

Walk each form in FORMS as if by WALK-FORM.

FORMS is a list of FORMS.

ENV is the environment in which to walk the forms.

Returns a list containing the results of walking each form, if *WALK-RESULT-TYPE* is LIST. Otherwise returns NIL.

Package

cl-form-types.

Source

walker.lisp.

Function: walk-lambda-list (list env)

Walk an ordinary lambda-list.

LIST is the lambda-list.

ENV is the environment in which the correspondign function definition is found.

Returns two values:

1. The new lambda-list.

2. List of variables introduced by the lambda-list.

Package

cl-form-types.

Source

walker.lisp.

Function: walk-local-fn (def env)

Walk a local function definition as by FLET or LABELS.

DEF the local function definition.

ENV the environment in which to walk the definition.

Package

cl-form-types.

Source

walker.lisp.

Function: walk-new-form (form env)

Walk the subforms in a new form returned by the walk function.

Package

cl-form-types.

Source

walker.lisp.


Next: , Previous: , Up: Internals   [Contents][Index]

6.2.5 Generic functions

Generic Function: block-type-walk-list-form (operator operands env)

Extract RETURN-FROM types from a function call expression form appearing within a BLOCK form.

Package

cl-form-types.

Source

block-types.lisp.

Methods
Method: block-type-walk-list-form ((operator (eql labels)) operands env)
Method: block-type-walk-list-form ((operator (eql flet)) operands env)
Method: block-type-walk-list-form ((operator (eql function)) operands env)
Method: block-type-walk-list-form ((operator (eql load-time-value)) operands env)
Method: block-type-walk-list-form ((operator (eql return-from)) operands env)

Method for RETURN-FROM forms.

If the block name is equal to *BLOCK-NAME* and *IN-BLOCK* is true, the type of the result form as if by FORM-TYPE% is returned, as well as the types of any nested RETURN-FROM forms.

Method: block-type-walk-list-form ((operator (eql block)) operands env)
Method: block-type-walk-list-form (operator operands env)
Generic Reader: form (condition)
Package

cl-form-types.

Methods
Reader Method: form ((condition malformed-form-error))
Source

form-types.lisp.

Target Slot

form.

Generic Reader: operands (condition)
Package

cl-form-types.

Methods
Reader Method: operands ((condition unknown-special-operator))
Source

form-types.lisp.

Target Slot

operands.

Generic Reader: operator (condition)
Package

cl-form-types.

Methods
Reader Method: operator ((condition unknown-special-operator))
Source

form-types.lisp.

Target Slot

operator.

Generic Function: special-form-type (operator operands env)

Determine the type of a special form.

OPERATOR is the form operator, which must name a special operator.

OPERANDS is the for argument list.

ENV is the environment in which the form is found.

Package

cl-form-types.

Source

form-types.lisp.

Methods
Method: special-form-type ((operator (eql block)) operands env)
Source

block-types.lisp.

Method: special-form-type ((operator (eql labels)) operands env)
Method: special-form-type ((operator (eql flet)) operands env)
Method: special-form-type ((operator (eql let*)) operands env)
Method: special-form-type ((operator (eql let)) operands env)
Method: special-form-type ((operator (eql symbol-macrolet)) operands env)
Method: special-form-type ((operator (eql macrolet)) operands env)
Method: special-form-type ((operator (eql return-from)) operands env)
Method: special-form-type ((operator (eql throw)) operands env)
Method: special-form-type ((operator (eql go)) operands env)
Method: special-form-type ((operator (eql tagbody)) operands env)
Method: special-form-type ((operator (eql locally)) operands env)
Method: special-form-type ((operator (eql unwind-protect)) operands env)
Method: special-form-type ((operator (eql eval-when)) operands env)
Method: special-form-type ((operator (eql progv)) operands env)
Method: special-form-type ((operator (eql progn)) operands env)
Method: special-form-type ((operator (eql multiple-value-prog1)) operands env)
Method: special-form-type ((operator (eql multiple-value-call)) operands env)
Method: special-form-type ((operator (eql if)) operands env)
Method: special-form-type ((operator (eql setq)) operands env)
Method: special-form-type ((operator (eql load-time-value)) operands env)
Method: special-form-type ((operator (eql the)) operands env)
Method: special-form-type ((operator (eql function)) operands env)
Method: special-form-type ((operator (eql quote)) operands env)
Method: special-form-type (operator arguments env)

Determine the type of a function call expression.

OPERATOR is the expression operator, which may be a special operator.

ARGUMENTS is the list of arguments following the operator.

ENV is the environment in which the expression is found.

Method: special-form-type :around (operator operands env)
Generic Function: walk-list-form (operator operands env)

Walk a list form.

OPERATOR is the form operator.

OPERANDS is the form’s operand list.

ENV is the environment in which to walk the form.

Package

cl-form-types.

Source

walker.lisp.

Methods
Method: walk-list-form ((operator (eql sb-int:named-lambda)) operands env)
Method: walk-list-form ((operator (eql sb-kernel:the*)) operands env)
Method: walk-list-form ((operator (eql truly-the)) operands env)
Method: walk-list-form ((operator (eql symbol-macrolet)) operands env)
Method: walk-list-form ((operator (eql macrolet)) operands env)
Method: walk-list-form ((operator (eql let*)) operands env)
Method: walk-list-form ((operator (eql let)) operands env)
Method: walk-list-form ((operator (eql labels)) operands env)
Method: walk-list-form ((operator (eql flet)) operands env)
Method: walk-list-form ((operator (eql function)) operands env)
Method: walk-list-form ((operator (eql the)) operands env)
Method: walk-list-form ((operator (eql setq)) operands env)
Method: walk-list-form ((operator (eql quote)) operands env)
Method: walk-list-form ((operator (eql load-time-value)) operands env)
Method: walk-list-form ((operator (eql tagbody)) operands env)
Method: walk-list-form ((operator (eql return-from)) operands env)
Method: walk-list-form ((operator (eql go)) operands env)
Method: walk-list-form ((operator (eql locally)) operands env)
Method: walk-list-form ((operator (eql eval-when)) operands env)
Method: walk-list-form ((operator (eql block)) operands env)
Method: walk-list-form (operator operands env)

Next: , Previous: , Up: Internals   [Contents][Index]

6.2.6 Structures

Structure: values-type-spec

Parse VALUES type specifier.

TYPES is the list of all type specifiers in the order in which they appear. Lambda list keywords are removed from this list.

OPTIONAL-START is the index at which the &OPTIONAL keyword is found in the type specifier list. NIL if there is no &OPTIONAL keyword.

REST-P is true if the type specifier list contains an &REST keyword.

REST-TYPE is the &REST type specifier

ALLOW-OTHER-KEYS is true if the type specifier list contains the keyword &ALLOW-OTHER-KEYS.

OTHER is a list of the elements following the last applicable valid component of the VALUES type specifier list. If non-NIL, this indicates a malformed VALUES type specifier.

Package

cl-form-types.

Source

form-types.lisp.

Direct superclasses

structure-object.

Direct slots
Slot: types
Readers

values-type-spec-types.

Writers

(setf values-type-spec-types).

Slot: optional-start
Readers

values-type-spec-optional-start.

Writers

(setf values-type-spec-optional-start).

Slot: rest-p
Readers

values-type-spec-rest-p.

Writers

(setf values-type-spec-rest-p).

Slot: rest-type
Readers

values-type-spec-rest-type.

Writers

(setf values-type-spec-rest-type).

Slot: allow-other-keys
Readers

values-type-spec-allow-other-keys.

Writers

(setf values-type-spec-allow-other-keys).

Slot: other
Readers

values-type-spec-other.

Writers

(setf values-type-spec-other).


Previous: , Up: Internals   [Contents][Index]

6.2.7 Types

Type: function-name ()
Package

cl-form-types.

Source

form-types.lisp.


Appendix A Indexes


Next: , Previous: , Up: Indexes   [Contents][Index]

A.1 Concepts


Next: , Previous: , Up: Indexes   [Contents][Index]

A.2 Functions

Jump to:   (  
B   C   E   F   G   L   M   N   O   P   R   S   V   W  
Index Entry  Section

(
(setf values-type-spec-allow-other-keys): Private ordinary functions
(setf values-type-spec-optional-start): Private ordinary functions
(setf values-type-spec-other): Private ordinary functions
(setf values-type-spec-rest-p): Private ordinary functions
(setf values-type-spec-rest-type): Private ordinary functions
(setf values-type-spec-types): Private ordinary functions

B
block-type-walk-form: Private ordinary functions
block-type-walk-list-form: Private generic functions
block-type-walk-list-form: Private generic functions
block-type-walk-list-form: Private generic functions
block-type-walk-list-form: Private generic functions
block-type-walk-list-form: Private generic functions
block-type-walk-list-form: Private generic functions
block-type-walk-list-form: Private generic functions
block-type-walk-list-form: Private generic functions
block-type-walk-local-fn: Private ordinary functions

C
combine-values-types: Private ordinary functions
constant-form-value: Private ordinary functions
constant-type: Private ordinary functions
copy-values-type-spec: Private ordinary functions
custom-form-type: Public generic functions
custom-form-type: Public generic functions
custom-form-type: Public generic functions
custom-form-type: Public generic functions
custom-form-type: Public generic functions
custom-form-type: Public generic functions
custom-form-type: Public generic functions
custom-form-type: Public generic functions
custom-form-type: Public generic functions

E
expand-compiler-macros: Private ordinary functions
expand-form-type: Private ordinary functions
extract-return-from-types: Private ordinary functions

F
flet-form-type: Private ordinary functions
form: Private generic functions
form: Private generic functions
form-type: Public ordinary functions
form-type%: Private ordinary functions
form-types: Public ordinary functions
Function, (setf values-type-spec-allow-other-keys): Private ordinary functions
Function, (setf values-type-spec-optional-start): Private ordinary functions
Function, (setf values-type-spec-other): Private ordinary functions
Function, (setf values-type-spec-rest-p): Private ordinary functions
Function, (setf values-type-spec-rest-type): Private ordinary functions
Function, (setf values-type-spec-types): Private ordinary functions
Function, block-type-walk-form: Private ordinary functions
Function, block-type-walk-local-fn: Private ordinary functions
Function, combine-values-types: Private ordinary functions
Function, constant-form-value: Private ordinary functions
Function, constant-type: Private ordinary functions
Function, copy-values-type-spec: Private ordinary functions
Function, expand-compiler-macros: Private ordinary functions
Function, expand-form-type: Private ordinary functions
Function, extract-return-from-types: Private ordinary functions
Function, flet-form-type: Private ordinary functions
Function, form-type: Public ordinary functions
Function, form-type%: Private ordinary functions
Function, form-types: Public ordinary functions
Function, lambda-expression-type: Private ordinary functions
Function, let-form-type: Private ordinary functions
Function, list-form-type: Private ordinary functions
Function, local-function-type: Private ordinary functions
Function, local-function-types: Private ordinary functions
Function, make-values-type-spec: Private ordinary functions
Function, maybe-constant-form-value: Private ordinary functions
Function, nth-form-type: Public ordinary functions
Function, nth-value-type: Public ordinary functions
Function, parse-values-type: Private ordinary functions
Function, return-default-type: Public ordinary functions
Function, subst-local-function-types: Private ordinary functions
Function, values-type-spec-allow-other-keys: Private ordinary functions
Function, values-type-spec-optional-start: Private ordinary functions
Function, values-type-spec-other: Private ordinary functions
Function, values-type-spec-p: Private ordinary functions
Function, values-type-spec-rest-p: Private ordinary functions
Function, values-type-spec-rest-type: Private ordinary functions
Function, values-type-spec-types: Private ordinary functions
Function, variable-type: Private ordinary functions
Function, walk-body: Private ordinary functions
Function, walk-fn-def: Private ordinary functions
Function, walk-form: Private ordinary functions
Function, walk-form%: Private ordinary functions
Function, walk-forms: Private ordinary functions
Function, walk-lambda-list: Private ordinary functions
Function, walk-local-fn: Private ordinary functions
Function, walk-new-form: Private ordinary functions

G
Generic Function, block-type-walk-list-form: Private generic functions
Generic Function, custom-form-type: Public generic functions
Generic Function, form: Private generic functions
Generic Function, operands: Private generic functions
Generic Function, operator: Private generic functions
Generic Function, special-form-type: Private generic functions
Generic Function, walk-list-form: Private generic functions

L
lambda-expression-type: Private ordinary functions
let-form-type: Private ordinary functions
list-form-type: Private ordinary functions
lm: Private macros
local-function-type: Private ordinary functions
local-function-types: Private ordinary functions

M
Macro, lm: Private macros
Macro, match-form: Private macros
Macro, with-default-type-restart: Private macros
Macro, with-result: Private macros
make-values-type-spec: Private ordinary functions
match-form: Private macros
maybe-constant-form-value: Private ordinary functions
Method, block-type-walk-list-form: Private generic functions
Method, block-type-walk-list-form: Private generic functions
Method, block-type-walk-list-form: Private generic functions
Method, block-type-walk-list-form: Private generic functions
Method, block-type-walk-list-form: Private generic functions
Method, block-type-walk-list-form: Private generic functions
Method, block-type-walk-list-form: Private generic functions
Method, custom-form-type: Public generic functions
Method, custom-form-type: Public generic functions
Method, custom-form-type: Public generic functions
Method, custom-form-type: Public generic functions
Method, custom-form-type: Public generic functions
Method, custom-form-type: Public generic functions
Method, custom-form-type: Public generic functions
Method, custom-form-type: Public generic functions
Method, form: Private generic functions
Method, operands: Private generic functions
Method, operator: Private generic functions
Method, special-form-type: Private generic functions
Method, special-form-type: Private generic functions
Method, special-form-type: Private generic functions
Method, special-form-type: Private generic functions
Method, special-form-type: Private generic functions
Method, special-form-type: Private generic functions
Method, special-form-type: Private generic functions
Method, special-form-type: Private generic functions
Method, special-form-type: Private generic functions
Method, special-form-type: Private generic functions
Method, special-form-type: Private generic functions
Method, special-form-type: Private generic functions
Method, special-form-type: Private generic functions
Method, special-form-type: Private generic functions
Method, special-form-type: Private generic functions
Method, special-form-type: Private generic functions
Method, special-form-type: Private generic functions
Method, special-form-type: Private generic functions
Method, special-form-type: Private generic functions
Method, special-form-type: Private generic functions
Method, special-form-type: Private generic functions
Method, special-form-type: Private generic functions
Method, special-form-type: Private generic functions
Method, special-form-type: Private generic functions
Method, special-form-type: Private generic functions
Method, special-form-type: Private generic functions
Method, walk-list-form: Private generic functions
Method, walk-list-form: Private generic functions
Method, walk-list-form: Private generic functions
Method, walk-list-form: Private generic functions
Method, walk-list-form: Private generic functions
Method, walk-list-form: Private generic functions
Method, walk-list-form: Private generic functions
Method, walk-list-form: Private generic functions
Method, walk-list-form: Private generic functions
Method, walk-list-form: Private generic functions
Method, walk-list-form: Private generic functions
Method, walk-list-form: Private generic functions
Method, walk-list-form: Private generic functions
Method, walk-list-form: Private generic functions
Method, walk-list-form: Private generic functions
Method, walk-list-form: Private generic functions
Method, walk-list-form: Private generic functions
Method, walk-list-form: Private generic functions
Method, walk-list-form: Private generic functions
Method, walk-list-form: Private generic functions
Method, walk-list-form: Private generic functions

N
nth-form-type: Public ordinary functions
nth-value-type: Public ordinary functions

O
operands: Private generic functions
operands: Private generic functions
operator: Private generic functions
operator: Private generic functions

P
parse-values-type: Private ordinary functions

R
return-default-type: Public ordinary functions

S
special-form-type: Private generic functions
special-form-type: Private generic functions
special-form-type: Private generic functions
special-form-type: Private generic functions
special-form-type: Private generic functions
special-form-type: Private generic functions
special-form-type: Private generic functions
special-form-type: Private generic functions
special-form-type: Private generic functions
special-form-type: Private generic functions
special-form-type: Private generic functions
special-form-type: Private generic functions
special-form-type: Private generic functions
special-form-type: Private generic functions
special-form-type: Private generic functions
special-form-type: Private generic functions
special-form-type: Private generic functions
special-form-type: Private generic functions
special-form-type: Private generic functions
special-form-type: Private generic functions
special-form-type: Private generic functions
special-form-type: Private generic functions
special-form-type: Private generic functions
special-form-type: Private generic functions
special-form-type: Private generic functions
special-form-type: Private generic functions
special-form-type: Private generic functions
subst-local-function-types: Private ordinary functions

V
values-type-spec-allow-other-keys: Private ordinary functions
values-type-spec-optional-start: Private ordinary functions
values-type-spec-other: Private ordinary functions
values-type-spec-p: Private ordinary functions
values-type-spec-rest-p: Private ordinary functions
values-type-spec-rest-type: Private ordinary functions
values-type-spec-types: Private ordinary functions
variable-type: Private ordinary functions

W
walk-body: Private ordinary functions
walk-fn-def: Private ordinary functions
walk-form: Private ordinary functions
walk-form%: Private ordinary functions
walk-forms: Private ordinary functions
walk-lambda-list: Private ordinary functions
walk-list-form: Private generic functions
walk-list-form: Private generic functions
walk-list-form: Private generic functions
walk-list-form: Private generic functions
walk-list-form: Private generic functions
walk-list-form: Private generic functions
walk-list-form: Private generic functions
walk-list-form: Private generic functions
walk-list-form: Private generic functions
walk-list-form: Private generic functions
walk-list-form: Private generic functions
walk-list-form: Private generic functions
walk-list-form: Private generic functions
walk-list-form: Private generic functions
walk-list-form: Private generic functions
walk-list-form: Private generic functions
walk-list-form: Private generic functions
walk-list-form: Private generic functions
walk-list-form: Private generic functions
walk-list-form: Private generic functions
walk-list-form: Private generic functions
walk-list-form: Private generic functions
walk-local-fn: Private ordinary functions
walk-new-form: Private ordinary functions
with-default-type-restart: Private macros
with-result: Private macros

Jump to:   (  
B   C   E   F   G   L   M   N   O   P   R   S   V   W  

Next: , Previous: , Up: Indexes   [Contents][Index]

A.3 Variables

Jump to:   *   +  
A   C   F   O   R   S   T  
Index Entry  Section

*
*block-name*: Private special variables
*block-types*: Private special variables
*constant-eql-types*: Private special variables
*expand-compiler-macros*: Private special variables
*handle-sb-lvars*: Public special variables
*in-block*: Private special variables
*local-fns*: Private special variables
*use-local-declared-types*: Private special variables
*walk-fn*: Private special variables
*walk-result-type*: Private special variables

+
+cl-special-forms+: Private constants

A
allow-other-keys: Private structures

C
Constant, +cl-special-forms+: Private constants

F
form: Public conditions

O
operands: Public conditions
operator: Public conditions
optional-start: Private structures
other: Private structures

R
rest-p: Private structures
rest-type: Private structures

S
Slot, allow-other-keys: Private structures
Slot, form: Public conditions
Slot, operands: Public conditions
Slot, operator: Public conditions
Slot, optional-start: Private structures
Slot, other: Private structures
Slot, rest-p: Private structures
Slot, rest-type: Private structures
Slot, types: Private structures
Special Variable, *block-name*: Private special variables
Special Variable, *block-types*: Private special variables
Special Variable, *constant-eql-types*: Private special variables
Special Variable, *expand-compiler-macros*: Private special variables
Special Variable, *handle-sb-lvars*: Public special variables
Special Variable, *in-block*: Private special variables
Special Variable, *local-fns*: Private special variables
Special Variable, *use-local-declared-types*: Private special variables
Special Variable, *walk-fn*: Private special variables
Special Variable, *walk-result-type*: Private special variables

T
types: Private structures

Jump to:   *   +  
A   C   F   O   R   S   T  

Previous: , Up: Indexes   [Contents][Index]

A.4 Data types

Jump to:   B   C   F   M   P   S   T   U   V   W  
Index Entry  Section

B
block-types.lisp: The cl-form-types/src/block-types․lisp file

C
cl-form-types: The cl-form-types system
cl-form-types: The cl-form-types package
cl-form-types.asd: The cl-form-types/cl-form-types․asd file
cl-form-types.walker: The cl-form-types․walker package
cl-functions.lisp: The cl-form-types/src/cl-functions․lisp file
Condition, malformed-form-error: Public conditions
Condition, unknown-special-operator: Public conditions

F
File, block-types.lisp: The cl-form-types/src/block-types․lisp file
File, cl-form-types.asd: The cl-form-types/cl-form-types․asd file
File, cl-functions.lisp: The cl-form-types/src/cl-functions․lisp file
File, form-types.lisp: The cl-form-types/src/form-types․lisp file
File, package.lisp: The cl-form-types/src/package․lisp file
File, walker.lisp: The cl-form-types/src/walker․lisp file
form-types.lisp: The cl-form-types/src/form-types․lisp file
function-name: Private types

M
malformed-form-error: Public conditions
Module, src: The cl-form-types/src module

P
Package, cl-form-types: The cl-form-types package
Package, cl-form-types.walker: The cl-form-types․walker package
package.lisp: The cl-form-types/src/package․lisp file

S
src: The cl-form-types/src module
Structure, values-type-spec: Private structures
System, cl-form-types: The cl-form-types system

T
Type, function-name: Private types

U
unknown-special-operator: Public conditions

V
values-type-spec: Private structures

W
walker.lisp: The cl-form-types/src/walker․lisp file

Jump to:   B   C   F   M   P   S   T   U   V   W