cleavir ctype
1.0.0Interface to client type systems.
The cleavir-ctype
system defines an interface for Cleavir to interact with a client's type system. This is necessary because the standard hook for working with types, cl:subtypep
, cannot be used to efficiently implement the kind of type operations Cleavir needs. Clients may have more efficient representations than type specifiers, and may have operations for manipulating these representations more generally and efficiently.
This is not an implementation of the type system in itself. Without client customization, cl:subtypep
will be used.
cleavir-ctype
consists of three rough subcomponents: type operations, type construction, and type readers. Type operations are operations on types, such as subtypep
and conjoin
. Type construction functions create some client representation of a type, and type readers get information from these client representations. Throughout Cleavir, various operators refer to "ctypes" rather than "types" to mean these representations.
Type operations
Besides subtypep
, there are conjoin
, disjoin
, negate
, subtract
, and disjointp
. These essentially continue the CL standard's treatment of types as sets. disjointp
, which determines if two ctypes contain any common elements, is especially important for optimization.
Type construction
The system contains generic functions for the various kinds of types defined by the standard - array types, real ranges, etc. These functions generally take an object representing the client as a parameter, so that methods may be defined, and then take other ctypes as more parameters.
Handling of values
The cl:values
types present some issue. The standard allows single-value types (that is, most of them) in essentially any place that values types are possible. Ctype is more explicit about the distinction. There are values-
versions of the type operations; these versions take values ctypes as arguments, and the non-values-
versions do not. coerce-to-values
, single-value
, primary
, and nth-value
can be used to convert to and from values ctypes.
System Information
Definition Index
-
CLEAVIR-CTYPE
No documentation provided.-
EXTERNAL FUNCTION COERCE-TO-VALUES
- CTYPE
- SYS
Given a non-values ctype, return a values ctype for it. This applies fuzz, so e.g. NULL -> (VALUES &OPTIONAL NULL &REST T) while CONS -> (VALUES CONS &REST T)
-
EXTERNAL FUNCTION CONJOIN
- SYSTEM
- &REST
- CTYPES
Return the conjunction (i.e. CL:AND) of non-values ctypes. See VALUES-CONJOIN
-
EXTERNAL FUNCTION DISJOIN
- SYSTEM
- &REST
- CTYPES
Return the disjunction (i.e. CL:OR) of non-values ctypes. See VALUES-DISJOIN
-
EXTERNAL FUNCTION DISJOINTP
- CT1
- CT2
- SYSTEM
Return true if the two non-values ctypes are disjoint. This is approximate: DISJOINTP may return false even if the ctypes are disjoint, if determining as much is impossible, or cannot be done efficiently. See VALUES-DISJOINTP
-
EXTERNAL FUNCTION FUNCTION-TOP
- SYSTEM
Return the ctype for CL:FUNCTION.
-
EXTERNAL FUNCTION PRIMARY
- VALUES-CTYPE
- SYSTEM
Return the ctype for the primary value of a values ctype.
-
EXTERNAL FUNCTION SINGLE-VALUE
- NON-VALUES-CTYPE
- SYSTEM
Given a non-values ctype, return the values ctype that means exactly one value of that type.
-
EXTERNAL FUNCTION VALUES-APPEND
- SYSTEM
- &REST
- CTYPES
Append the given values ctypes together. See VALUES-APPEND/2
-
EXTERNAL FUNCTION VALUES-CONJOIN
- SYSTEM
- &REST
- CTYPES
Return the conjunction of values ctypes. See CONJOIN
-
EXTERNAL FUNCTION VALUES-DISJOIN
- SYSTEM
- &REST
- CTYPES
Return the disjunction ov values ctypes. See DISJOIN
-
EXTERNAL FUNCTION VALUES-DISJOINTP
- VCT1
- VCT2
- SYSTEM
Return true if two values ctypes are disjoint. This is approximate: VALUES-DISJOINTP may return false evne if the ctypes are disjoint. See DISJOINTP
-
EXTERNAL FUNCTION VALUES-WDISJOIN
- SYSTEM
- &REST
- CTYPES
No documentation provided. -
EXTERNAL FUNCTION WDISJOIN
- SYSTEM
- &REST
- CTYPES
No documentation provided. -
EXTERNAL GENERIC-FUNCTION APPLY
- FCTYPE
- ACTYPE
- SYSTEM
Given a non-values ctype of a function, and the non-values ctype of a list of arguments, return a ctype for the return values from CL:APPLYing the function to those arguments.
-
EXTERNAL GENERIC-FUNCTION ARRAY
- ELEMENT
- DIMENSIONS
- SIMPLICITY
- SYSTEM
Given an element type specifier, dimensions specifier, and simplicity mark, return a ctype representing the array type. The element type specifier is either an upgraded non-values ctype, or the symbol *. The dimensions specifier is as in the CL type specifier ARRAY, but must be normalized to a list of dimensions (i.e. 4 is not valid, and must be replaced by (* * * *)). The simplicity mark is one of the symbols ARRAY or SIMPLE-ARRAY.
-
EXTERNAL GENERIC-FUNCTION ARRAY-DIMENSIONS
- ARRAY-CTYPE
- SYSTEM
Return the dimensions specifier of an array ctype. See ARRAYP
-
EXTERNAL GENERIC-FUNCTION ARRAY-ELEMENT-TYPE
- ARRAY-CTYPE
- SYSTEM
Return the element type of an array ctype. See ARRAYP
-
EXTERNAL GENERIC-FUNCTION ARRAY-SIMPLICITY
- ARRAY-CTYPE
- SYSTEM
Return the simplicity mark of an array ctype. See ARRAYP
-
EXTERNAL GENERIC-FUNCTION ARRAYP
- CTYPE
- SYSTEM
Return true iff the ctype is an array ctype.
-
EXTERNAL GENERIC-FUNCTION BASE-CHAR
- SYSTEM
Return the ctype representing CL:BASE-CHAR.
-
EXTERNAL GENERIC-FUNCTION BOTTOM
- SYSTEM
Return the bottom ctype, i.e. the ctype for CL:NIL. See VALUES-BOTTOM
-
EXTERNAL GENERIC-FUNCTION BOTTOM-P
- CTYPE
- SYSTEM
Return true if the given non-values ctype is the bottom ctype (i.e. CL:NIL). As this function is approximate, false may be returned even on a ctype equivalent to bottom. (For example, it may not be possible to determine this equivalence in the presence of SATISFIES types.)
-
EXTERNAL GENERIC-FUNCTION CHARACTER
- SYSTEM
Return the ctype representing CL:CHARACTER.
-
EXTERNAL GENERIC-FUNCTION CLASS
- CLASS
- SYSTEM
Given a class, return the ctype for that class.
-
EXTERNAL GENERIC-FUNCTION COMPILED-FUNCTION
- SYSTEM
Return the ctype for CL:COMPILED-FUNCTION. While COMPILED-FUNCTION = (SATISFIES COMPILED-FUNCTION-P), this function exists in case a client has a more specialized representation, for example to make clear that it is a subtype of FUNCTION.
-
EXTERNAL GENERIC-FUNCTION COMPLEX
- PART
- SYSTEM
Given a part type specifier, return a ctype for the complex type. The specifier may be either an upgraded non-values ctype or the symbol *.
-
EXTERNAL GENERIC-FUNCTION COMPLEX-PART-TYPE
- COMPLEX-CTYPE
- SYSTEM
Return the part type of a cl:complex ctype. See COMPLEXP
-
EXTERNAL GENERIC-FUNCTION COMPLEXP
- CTYPE
- SYSTEM
Return true if the ctype is a cl:complex ctype.
-
EXTERNAL GENERIC-FUNCTION CONJOIN/2
- CTYPE1
- CTYPE2
- SYSTEM
Return the conjunction (i.e. CL:AND) of two non-values ctypes. This function may be specialized, but should not be called directly: use CONJOIN. See CONJOIN
-
EXTERNAL GENERIC-FUNCTION CONJUNCTION-CTYPES
- CONJUNCTION-CTYPE
- SYSTEM
Given a conjunction ctype, return a list of the ctypes it is composed of, in some arbitrary order. This function must only be called on ctypes that CONJUNCTIONP is true of. See CONJUNCTIONP
-
EXTERNAL GENERIC-FUNCTION CONJUNCTIONP
- CTYPE
- SYSTEM
Return true iff the given non-values ctype is a conjunction ctype. Whether a given type specifier ends up as a conjunction ctype is client-dependent. For example, (and (integer 1 7) (integer 2 4)) may end up as a conjunction on some clients, but reduced to an integer type by others.
-
EXTERNAL GENERIC-FUNCTION CONS
- CAR
- CDR
- SYSTEM
Given two non-values ctypes, return the ctype of a cons type using them.
-
EXTERNAL GENERIC-FUNCTION CONS-CAR
- CONS-CTYPE
- SYSTEM
Given a cons ctype, return its car ctype. See CONSP
-
EXTERNAL GENERIC-FUNCTION CONS-CDR
- CONS-CTYPE
- SYSTEM
Given a cons ctype, return its cdr ctype. See CONSP
-
EXTERNAL GENERIC-FUNCTION CONSP
- CTYPE
- SYSTEM
Return true iff the ctype is a cons ctype.
-
EXTERNAL GENERIC-FUNCTION DISJOIN/2
- CTYPE1
- CTYPE2
- SYSTEM
Return the disjunction (i.e. CL:OR) of two non-values ctypes. This function may be specialized, but should not be called directly: use DISJOIN. See DISJOIN
-
EXTERNAL GENERIC-FUNCTION DISJUNCTION-CTYPES
- DISJUNCTION-CTYPE
- SYSTEM
Given a disjunction ctype, return a list of the ctypes it is composed of, in some arbitrary order. This function must only be called on ctypes that DISJUNCTIONP is true of. See DISJUNCTIONP
-
EXTERNAL GENERIC-FUNCTION DISJUNCTIONP
- CTYPE
- SYSTEM
Return true iff the given non-values ctype is a disjunction ctype. Whether a given type specifier ends up as a disjunction ctype is client dependent. For example, (or (integer 1 7) (integer 4 9)) may end up as a disjunction on some clients, but reduced to (integer 1 9) on others.
-
EXTERNAL GENERIC-FUNCTION FIXNUM
- SYSTEM
Return the ctype for CL:FIXNUM.
-
EXTERNAL GENERIC-FUNCTION FUNCALL
- SYSTEM
- FCTYPE
- &REST
- ACTYPES
Given a non-values ctype of a function, and a list of argument non-values ctypes, return a ctype for the return values from CL:APPLYing the function to those arguments.
-
EXTERNAL GENERIC-FUNCTION FUNCTION
- REQUIRED
- OPTIONAL
- REST
- KEYP
- KEYS
- ALLOW-OTHER-KEYS-P
- RETURNS
- SYSTEM
Return a ctype for a function type specifier. The first seven parameters represent the parsed lambda list. REQUIRED and OPTIONAL are lists of non-values ctypes, and REST is anon-values ctype. KEYP and ALLOW-OTHER-KEYS-P indicate the presences of &key and &allow-other-keys respectively. KEYS is a list of (keyword non-values-ctype) elements. RETURNS is the values ctype of the return values specified. Note that REST must always be provided. If the function does not actually accept more arguments, this should be indicated by REST being the bottom ctype.
-
EXTERNAL GENERIC-FUNCTION FUNCTION-ALLOW-OTHER-KEYS-P
- CTYPE
- SYSTEM
Return true iff the function ctype indicates a function that accepts unknown keyword arguments.
-
EXTERNAL GENERIC-FUNCTION FUNCTION-KEYS
- CTYPE
- SYSTEM
Return the key parameter ctypes for a function ctype. This will be in the form of a list ((keyword ctype) ...)
-
EXTERNAL GENERIC-FUNCTION FUNCTION-KEYSP
- CTYPE
- SYSTEM
Return true iff the function ctype indicates a function that accepts keyword arguments.
-
EXTERNAL GENERIC-FUNCTION FUNCTION-OPTIONAL
- CTYPE
- SYSTEM
Return the optional parameter ctypes of a function ctype.
-
EXTERNAL GENERIC-FUNCTION FUNCTION-REQUIRED
- CTYPE
- SYSTEM
Return the required parameter ctypes of a function ctype.
-
EXTERNAL GENERIC-FUNCTION FUNCTION-REST
- CTYPE
- SYSTEM
Return the rest parameter ctype of a function ctype.
-
EXTERNAL GENERIC-FUNCTION FUNCTION-VALUES
- CTYPE
- SYSTEM
Return the return values ctype of a function ctype.
-
EXTERNAL GENERIC-FUNCTION FUNCTIONP
- CTYPE
- SYSTEM
Return true iff the given non-values ctype is a function ctype.
-
EXTERNAL GENERIC-FUNCTION KEYWORD
- SYSTEM
Return the ctype representing CL:KEYWORD. While KEYWORD = (SATISFIES KEYWORD), this function exists in case a client has a more specialized representation, for example to make clear that it is a subtype of SYMBOL.
-
EXTERNAL GENERIC-FUNCTION MEMBER
- SYSTEM
- &REST
- ELEMENTS
Return the ctype corresponding to (cl:member ...elements...)
-
EXTERNAL GENERIC-FUNCTION MEMBER-MEMBERS
- SYSTEM
- MEMBER-CTYPE
Return a list of the members of the given member ctype, in arbitrary order. See MEMBER-P
-
EXTERNAL GENERIC-FUNCTION MEMBER-P
- SYSTEM
- NON-VALUES-CTYPE
Return true iff the ctype is a MEMBER ctype. Note that EQL types are treated as shorthand for MEMBER types.
-
EXTERNAL GENERIC-FUNCTION NEGATE
- CTYPE
- SYSTEM
Compute the negation of the given non-values ctype, as if using the NOT type specifier.
-
EXTERNAL GENERIC-FUNCTION NEGATION-CTYPE
- NEGATION-CTYPE
- SYSTEM
Given a negation ctype, return the ctype it is a negation of.
-
EXTERNAL GENERIC-FUNCTION NEGATIONP
- CTYPE
- SYSTEM
Return true iff the given non-values ctype is a negation ctype. Note that whether a given type specifier ends up as a conjunction ctype may be client-dependent.
-
EXTERNAL GENERIC-FUNCTION NTH-VALUE
- N
- CTYPE
- SYSTEM
Return the ctype for the Nth value of the given values ctype.
-
EXTERNAL GENERIC-FUNCTION RANGE
- KIND
- LOW
- HIGH
- SYSTEM
Given a kind, and interval designators, return a ctype. This function is used to construct ctypes for ranges of real numbers. The kind is one of the symbols INTEGER, RATIONAL, REAL, FLOAT, SHORT-FLOAT, SINGLE-FLOAT, DOUBLE-FLOAT, or LONG-FLOAT.
-
EXTERNAL GENERIC-FUNCTION RANGE-HIGH
- RANGE-CTYPE
- SYSTEM
Given a range ctype, return two values: The upper bound, and a boolean indicating whether the bound is exclusive. Non-bounds (i.e. *) are always non-exclusive. See RANGEP
-
EXTERNAL GENERIC-FUNCTION RANGE-KIND
- RANGE-CTYPE
- SYSTEM
Return the kind (e.g. INTEGER) of a range ctype. See RANGEP
-
EXTERNAL GENERIC-FUNCTION RANGE-LOW
- RANGE-CTYPE
- SYSTEM
Given a range ctype, return two values: The lower bound, and a boolean indicating whether the bound is exclusive. Non-bounds (i.e. *) are always non-exclusive. See RANGEP
-
EXTERNAL GENERIC-FUNCTION RANGEP
- CTYPE
- SYSTEM
Return true iff the ctype is a range ctype.
-
EXTERNAL GENERIC-FUNCTION SATISFIES
- FNAME
- SYSTEM
Return the ctype for (SATISFIES fname)
-
EXTERNAL GENERIC-FUNCTION SATISFIES-FNAME
- SATISFIES-CTYPE
- SYS
Return the function name of the given SATISFIES ctype.
-
EXTERNAL GENERIC-FUNCTION SATISFIESP
- CTYPE
- SYS
Return true iff the given non-values ctype is a SATISFIES ctype. Whether a given type specifier ends up as a satisfies ctype is client-dependent.
-
EXTERNAL GENERIC-FUNCTION STANDARD-CHAR
- SYSTEM
Return the ctype representing CL:STANDARD-CHAR.
-
EXTERNAL GENERIC-FUNCTION STRING
- DIMENSION
- SIMPLICITY
- SYSTEM
Given a dimension specifier, and simplicity mark, return a ctype representing the string type. The dimension specifier is either a nonnegative integer or the symbol *. The simplicity mark is one of the symbols ARRAY or SIMPLE-ARRAY.
-
EXTERNAL GENERIC-FUNCTION SUBTRACT
- CTYPE1
- CTYPE2
- SYSTEM
Compute the difference of the two non-values ctypes. ;;; (subtract c1 c2 s) = (conjoin/2 c1 (negate c2 s) s), but this can sometimes ;;; be done more efficiently. May not be called with values ctypes.
-
EXTERNAL GENERIC-FUNCTION SUBTYPEP
- CTYPE1
- CTYPE2
- SYSTEM
As CL:SUBTYPEP, but with non-values ctypes instead of type specifiers, no tnevironment, and a client parameter. See VALUES-SUBTYPEP
-
EXTERNAL GENERIC-FUNCTION TOP
- SYSTEM
Return the top ctype, i.e. the ctype for CL:T. See VALUES-TOP
-
EXTERNAL GENERIC-FUNCTION TOP-P
- CTYPE
- SYSTEM
Return true if the given non-values ctype is the top ctype (i.e. CL:T). As this function is approximate, false may be returned even on a ctype equivalent to top. (For example, it may not be possible to determine this equivalence in the presence of SATISFIES types.)
-
EXTERNAL GENERIC-FUNCTION UPGRADED-ARRAY-ELEMENT-TYPE
- CTYPE
- SYSTEM
As CL:UPGRADED-ARRAY-ELEMENT-TYPE, but with a non-values ctype instead of a type specifier, and a client parameter instead of an environment.
-
EXTERNAL GENERIC-FUNCTION UPGRADED-COMPLEX-PART-TYPE
- CTYPE
- SYSTEM
As CL:UPGRADED-COMPLEX-PART-TYPE, but with a non-values ctype instead of a type specifier, and a client parameter instead of an environment.
-
EXTERNAL GENERIC-FUNCTION VALUES
- REQUIRED
- OPTIONAL
- REST
- SYSTEM
Return a ctype for a values type specifier. The first four parameters represent the parsed lambda list. REQUIRED and OPTIONAL are lists of ctypes. REST is a ctype. The semantics of values types in the standard are self contradictory. This function uses the strict semantics described for the VALUES type specifier. A client expecting fuzziness, as it needs to to implement CL:THE, should apply that before using this function. See the parsing in the cleavir-environment system for an example of this. Strictness means that, for example, (values integer &rest nil) is disjoint from (values integer integer &rest nil), which is very different from how CL:THE works. Strict types are useful for when the compiler can derive exacting types; e.g. (values-list '(nil)) is of type (values null &rest nil) and cannot be zero values. Values ctypes are only used in certain contexts. See the documentation for other operators for more information.
-
EXTERNAL GENERIC-FUNCTION VALUES-APPEND/2
- CTYPE1
- CTYPE2
- SYSTEM
Given two values ctypes, append them. In more detail, if forms A and B have types Avt and Bvt, (values-append Avt Bvt) is the type of (multiple-value-call #'values A B). This operation is useful when dealing with multiple-value-call. This function may be specialized, but should not be called directly: Use VALUES-APPEND. See VALUES-APPEND
-
EXTERNAL GENERIC-FUNCTION VALUES-BOTTOM
- SYSTEM
Return the bottom values ctype. The bottom values ctype is equivalent to (values nil &rest nil) and represents no number of values - which is, importantly, a distinct type from (values &rest nil), which means exactly zero values. That is to say, there is no list of values that is of the bottom values ctype. See BOTTOM
-
EXTERNAL GENERIC-FUNCTION VALUES-BOTTOM-P
- CTYPE
- SYSTEM
Return true if the given values ctype is the bottom ctype (i.e. (VALUES NIL ...)). As this function is approximate, false may be returned even on a ctype equivalent to bottom.
-
EXTERNAL GENERIC-FUNCTION VALUES-CONJOIN/2
- CTYPE1
- CTYPE2
- SYSTEM
Given two values ctypes, return their conjunction. This function may be specialized, but should not be called directly: Use VALUES-CONJOIN. See VALUES-CONJOIN
-
EXTERNAL GENERIC-FUNCTION VALUES-DISJOIN/2
- CTYPE1
- CTYPE2
- SYSTEM
Given two values ctypes, return their disjunction. This function may be specialized, but should not be called directly: Use VALUES-DISJOIN. See VALUES-DISJOIN
-
EXTERNAL GENERIC-FUNCTION VALUES-OPTIONAL
- CTYPE
- SYSTEM
Return the optional component of a values ctype.
-
EXTERNAL GENERIC-FUNCTION VALUES-REQUIRED
- CTYPE
- SYSTEM
Return the required component of a values ctype.
-
EXTERNAL GENERIC-FUNCTION VALUES-REST
- CTYPE
- SYSTEM
Return the rest component of a values ctype.
-
EXTERNAL GENERIC-FUNCTION VALUES-SUBTYPEP
- CTYPE1
- CTYPE2
- SYSTEM
SUBTYPEP for values ctypes. Non-values ctypes are not permitted as arguments. See SUBTYPEP
-
EXTERNAL GENERIC-FUNCTION VALUES-TOP
- SYSTEM
Return the top values ctype. The top values ctype is equivalent to (values &rest t), representing any number of values, each of which may be of any type. See TOP
-
EXTERNAL GENERIC-FUNCTION VALUES-TOP-P
- CTYPE
- SYSTEM
Return true if the given values ctype is the top ctype (i.e. (VALUES &REST CL:T)). As this function is approximate, false may be returned even on a ctype equivalent to top.
-
EXTERNAL GENERIC-FUNCTION VALUES-WDISJOIN/2
- CTYPE1
- CTYPE2
- SYSTEM
No documentation provided. -
EXTERNAL GENERIC-FUNCTION WDISJOIN/2
- CTYPE1
- CTYPE2
- SYSTEM
No documentation provided.
-