1. Declarations
    1. declare
    2. always-bound
    3. block
    4. block-global
    5. hide
    6. bound-to-procedure
    7. enforce-argument-types
    8. export
    9. emit-external-prototypes-first
    10. disable-interrupts
    11. emit-import-library
    12. emit-types-file
    13. inline
    14. inline-global
    15. inline-limit
    16. unroll-limit
    17. keep-shadowed-macros
    18. local
    19. no-argc-checks
    20. no-bound-checks
    21. no-procedure-checks
    22. no-procedure-checks-for-usual-bindings
    23. no-procedure-checks-for-toplevel-bindings
    24. predicate
    25. profile
    26. pure
    27. number-type
    28. fixnum-arithmetic
    29. compile-syntax
    30. safe-globals
    31. specialize
    32. standard-bindings
    33. strict-types
    34. type
    35. extended-bindings
    36. usual-integrations
    37. unit
    38. unsafe
    39. unused
    40. uses


Declarations can be used to control compiler settings directly inside the compiled code and are always global in scope. In many (but not all) cases an associated command-line option exists. When in conflict, declarations override command-line options. When multiple declarations conflict, the one appearing textually last overrides any previous one.

Declarations can be used to improve performance and to give entities like procedures and variables special properties that can result in better performing code. Most of these declarations subtly change the semantics of standard Scheme code with respect to the declared entities, so care must be taken when using them.

Declarations are always ignored in csi (the interpreter) or in evaluated code.


[syntax] (declare DECLSPEC ...)

Process declaration specifiers. Declarations always override any command-line settings. Declarations are valid for the whole compilation-unit (source file), the position of the declaration in the source file can be arbitrary. Declarations are ignored in the interpreter but not in code evaluated at compile-time (by eval-when or in syntax extensions loaded via require-extension). DECLSPEC may be any of the following:


[declaration specifier] (always-bound IDENTIFIER ...)

Declares that the given variables are always bound and accesses to those have not to be checked.


[declaration specifier] (block)

Assume global variables are never redefined. This is the same as specifying the -block option.



[declaration specifier] (block-global IDENTIFIER ...)
[declaration specifier] (hide IDENTIFIER ...)

Declares that the toplevel bindings for IDENTIFIER ... should not be accessible from code in other compilation units or by eval. Access to toplevel bindings declared as block global is also more efficient. (declare (hide)) is equivalent to (declare (block)).


[declaration specifier] (bound-to-procedure IDENTIFIER ...)

Declares that the given identifiers are always bound to procedure values.


[declaration-specifier] (enforce-argument-types IDENTIFIER ...)

Declares that the toplevel procedures listed check the type of their arguments (either explicitly or by calling other enforcing procedures) and so a successfull invocation will indicate the arguments are of the types declared.


[declaration specifier] (export IDENTIFIER ...)

The opposite of hide. All given identifiers will be exported and all toplevel variables not listed will be hidden and not be accessible outside of this compilation unit.


[declaration specifier] (emit-external-prototypes-first)

Emit prototypes for callbacks defined with define-external before any other foreign declarations. Equivalent to giving the -emit-external-prototypes-first option to the compiler.


[declaration specifier] (disable-interrupts)

Disable timer-interrupts checks in the compiled program. Threads can not be preempted in main- or library-units that contain this declaration.


[declaration specifier] (emit-import-library MODULENAME | (MODULENAME FILENAME) ...)

Declares that any following definition of a module named MODULENAME should be written to an external file (either a specified one or a file named "MODULENAME.import.scm"). The compiler option -emit-import-library may also be used instead.

Note that the import library is only generated if it cannot be found in the current directory, or if it exists but is not equal to the one that would be generated.


[declaration specifier] (emit-types-file [FILENAME])

Enables generation of a types file for the current compilation unit, which will be written to the specified FILENAME or to <source-filename>.types in the current directory. This filename can be overridden with the -emit-types-file command line flag, which takes precedence over this declaration.


[declaration specifier] (inline)
[declaration specifier] (not inline)
[declaration specifier] (inline IDENTIFIER ...)
[declaration specifier] (not inline IDENTIFIER ...)

If given without an identifier-list, inlining of known procedures is enabled (this is equivalent to the -inline compiler option). When an identifier-list is given, then inlining is enabled only for the specified global procedures. The negated forms (not inline) and (not inline IDENTIFIER) disable global inlining, or inlining for the given global procedures only, respectively.


 [declaration specifier] (inline-global)
 [declaration specifier] (not inline-global)
 [declaration specifier] (inline-global IDENTIFIER ...)
 [declaration specifier] (not inline-global IDENTIFIER ...)

Declare that then given toplevel procedures (or all) are subject to cross-module inlining. Potentially inlinable procedures in the current compilation unit will be written to an external <source-filename>.inline file in the current directory. Globally inlinable procedures from other compilation units referred to via (declare (uses ...)) or require-extension are loaded from .inline files (if available in the current include path) and inlined in the current compilation unit.

Enabling global inlining implies (declare (inline)).


[declaration specifier] (inline-limit THRESHOLD)

Sets the maximum size of procedures which may potentially be inlined. The default threshold is 20.


[declaration specifier] (unroll-limit LIMIT)

Sets the maximum number of times a self-recursive call is inlined and so effectively "unrolled". The default limit is 1.


[declaration specifier] (keep-shadowed-macros)

Normally, when a toplevel variable is assigned or defined that has the same name as a macro, the macro-definition will be removed (in addition to showing a warning). This declaration will disable the removal of the macro.


[declaration specifier] (local)
[declaration specifier] (local IDENTIFIER ...)

Declares that the listed (or all) toplevel variables defined in the current compilation unit are not modified from code outside of this compilation unit. See also the documentation for the -local compiler option about the implications of this.


[declaration specifier] (no-argc-checks)

Disables argument count checking.


[declaration specifier] (no-bound-checks)

Disables the bound-checking of toplevel bindings.


[declaration specifier] (no-procedure-checks)

Disables checking of values in operator position for being of procedure type.


[declaration specifier] (no-procedure-checks-for-usual-bindings)

Disables checking of procedures for the default standard- and extended toplevel bindings.


[declaration specifier] (no-procedure-checks-for-toplevel-bindings)

Disables checking of procedures for calls to procedures referenced via a toplevel variable (calls to explicitly named procedures).


[declaration specifier] (predicate (IDENTIFIER TYPE) ...)

Marks the global procedure IDENTIFIER as a predicate on TYPE.


[declaration specifier] (profile IDENTIFIER ...)

Enable profiling exclusively for given identifiers. Normally the compiler enables profiling decorations for all globally defined procedures. With this declaration, profiling can be enabled for selected procedures.


[declaration specifier] (pure IDENTIFIER ...)

Declares the procedures with the names IDENTIFIER ... as referentially transparent, that is, as not having any side effects. This can help the compiler to remove non-side-effecting expressions.



[declaration specifier] ([number-type] TYPE)
[declaration specifier] (fixnum-arithmetic)

Declares that only numbers of the given type are used. TYPE may be fixnum or generic (which is the default).


[declaration specifier] (compile-syntax)

Equivalent to the compiler option of the same name - macros defined in the compiled code are also made available at runtime.


[declaration specifier] (safe-globals)

Assumes variables assigned in the current compilation unit are always bound and that any calls to these variables can always be assumed to be calls to proper procedures.


[declaration specifier] (specialize)

Enables specialization. This is equivalent to passing the -specialize option to the compiler.


[declaration specifier] (standard-bindings IDENTIFIER ...)
[declaration specifier] (not standard-bindings IDENTIFIER ...)

Declares that all given standard procedures (or all if no symbols are specified) are never globally redefined. If not is specified, then all but the given standard bindings are assumed to be never redefined.


[declaration specifier] (strict-types)

Declares that the type of variables is not changed by assignment. Equivalent to giving the -strict-types compiler option.


 [declaration specifier] (type (IDENTIFIER TYPE) ...)

Declares toplevel procedures to have a specific type for scrutiny. IDENTIFIER should name a toplevel variable and TYPE should be a type specification. A type-declaration overrides any previous declaration for the same identifier. See also Types for more information about using types, the syntax of type-specifiers and a more convenient type-declaration syntax (:).


[declaration specifier] (extended-bindings IDENTIFIER ...)
[declaration specifier] (not extended-bindings IDENTIFIER ...)

Declares that all given non-standard and CHICKEN-specific procedures (or all if no symbols are specified) are never globally redefined. If not is specified, then all but the given extended bindings are assumed to be never redefined.


[declaration specifier] (usual-integrations IDENTIFIER ...)
[declaration specifier] (not usual-integrations IDENTIFIER ...)

Declares that all given standard and extended bindings (or all if no symbols are specified) are never globally redefined. If not is specified, then all but the given standard and extended bindings are assumed to be never redefined. Note that this is the default behaviour, unless the -no-usual-integrations option has been given.


[declaration specifier] (unit IDENTIFIER)

Specify compilation unit-name (if this is a library)


[declaration specifier] (unsafe)
[declaration specifier] (not safe)

Do not generate safety-checks. This is the same as specifying the -unsafe option. Also implies

(declare (no-bound-checks) (no-procedure-checks) (no-argc-checks))


[declaration specifier] (unused IDENTIFIER ...)

Disables any warnings when the global variable IDENTIFIER is not defined but used, or defined but never used and not exported.


[declaration specifier] (uses IDENTIFIER ...)

Gives a list of used library-units. Before the toplevel-expressions of the main-module are executed, all used units evaluate their toplevel-expressions in the order in which they appear in this declaration. If a library unit A uses another unit B, then B's toplevel expressions are evaluated before A's. Furthermore, the used symbols are registered as features during compile-time, so cond-expand knows about them.

Previous: Types

Next: Extensions