File: Declarations.html

package info (click to toggle)
chicken 5.2.0-2
  • links: PTS
  • area: main
  • in suites: bullseye
  • size: 32,804 kB
  • sloc: ansic: 579,676; lisp: 71,716; tcl: 1,445; sh: 576; makefile: 58
file content (70 lines) | stat: -rw-r--r-- 17,384 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<!doctype html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="manual.css" type="text/css" /></head>
<title>Chicken &raquo; Declarations</title>
<meta name="viewport" content="initial-scale=1" /></html>
<body>
<div id="body">
<div id="main">
<div id="toc">
<h2 class="toc">TOC &raquo;</h2>
<ul class="toc">
<li><a href="#sec:Declarations">Declarations</a>
<ul>
<li><a href="#sec:declare">declare</a></li>
<li><a href="#sec:always-bound">always-bound</a></li>
<li><a href="#sec:block">block</a></li>
<li><a href="#sec:block-global">block-global</a></li>
<li><a href="#sec:hide">hide</a></li>
<li><a href="#sec:bound-to-procedure">bound-to-procedure</a></li>
<li><a href="#sec:enforce-argument-types">enforce-argument-types</a></li>
<li><a href="#sec:export">export</a></li>
<li><a href="#sec:emit-external-prototypes-first">emit-external-prototypes-first</a></li>
<li><a href="#sec:disable-interrupts">disable-interrupts</a></li>
<li><a href="#sec:emit-import-library">emit-import-library</a></li>
<li><a href="#sec:inline">inline</a></li>
<li><a href="#sec:inline-global">inline-global</a></li>
<li><a href="#sec:inline-limit">inline-limit</a></li>
<li><a href="#sec:unroll-limit">unroll-limit</a></li>
<li><a href="#sec:keep-shadowed-macros">keep-shadowed-macros</a></li>
<li><a href="#sec:local">local</a></li>
<li><a href="#sec:no-argc-checks">no-argc-checks</a></li>
<li><a href="#sec:no-bound-checks">no-bound-checks</a></li>
<li><a href="#sec:no-procedure-checks">no-procedure-checks</a></li>
<li><a href="#sec:no-procedure-checks-for-usual-bindings">no-procedure-checks-for-usual-bindings</a></li>
<li><a href="#sec:no-procedure-checks-for-toplevel-bindings">no-procedure-checks-for-toplevel-bindings</a></li>
<li><a href="#sec:predicate">predicate</a></li>
<li><a href="#sec:profile">profile</a></li>
<li><a href="#sec:pure">pure</a></li>
<li><a href="#sec:number-type">number-type</a></li>
<li><a href="#sec:fixnum-arithmetic">fixnum-arithmetic</a></li>
<li><a href="#sec:compile-syntax">compile-syntax</a></li>
<li><a href="#sec:safe-globals">safe-globals</a></li>
<li><a href="#sec:specialize">specialize</a></li>
<li><a href="#sec:standard-bindings">standard-bindings</a></li>
<li><a href="#sec:strict-types">strict-types</a></li>
<li><a href="#sec:type">type</a></li>
<li><a href="#sec:extended-bindings">extended-bindings</a></li>
<li><a href="#sec:usual-integrations">usual-integrations</a></li>
<li><a href="#sec:unit">unit</a></li>
<li><a href="#sec:unsafe">unsafe</a></li>
<li><a href="#sec:unused">unused</a></li>
<li><a href="#sec:uses">uses</a></li></ul></li></ul></div><h2 id="sec:Declarations"><a href="#sec:Declarations">Declarations</a></h2><p>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.</p><p>Declarations can be used to improve performance and to give entities like procedures are 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.</p><p>Declarations are always ignored in <tt>csi</tt> (the interpreter) or in evaluated code.</p><h3 id="sec:declare"><a href="#sec:declare">declare</a></h3>
<dl class="defsig">
<dt class="defsig" id="def:declare"><span class="sig"><tt>(declare DECLSPEC ...)</tt></span><span class="type">syntax</span></dt>
<dd class="defsig"><p>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 <tt>eval-when</tt> or in syntax extensions loaded via <tt>require-extension</tt>). <tt>DECLSPEC</tt> may be any of the following:</p></dd></dl><h3 id="sec:always-bound"><a href="#sec:always-bound">always-bound</a></h3><pre>[declaration specifier] (always-bound IDENTIFIER ...)</pre><p>Declares that the given variables are always bound and accesses to those have not to be checked.</p><h3 id="sec:block"><a href="#sec:block">block</a></h3><pre>[declaration specifier] (block)</pre><p>Assume global variables are never redefined. This is the same as specifying the <tt>-block</tt> option.</p><h3 id="sec:block-global"><a href="#sec:block-global">block-global</a></h3><h3 id="sec:hide"><a href="#sec:hide">hide</a></h3><pre>[declaration specifier] (block-global IDENTIFIER ...)
[declaration specifier] (hide IDENTIFIER ...)</pre><p>Declares that the toplevel bindings for <tt>IDENTIFIER ...</tt> should not be accessible from code in other compilation units or by <tt>eval</tt>. Access to toplevel bindings declared as block global is also more efficient. <tt>(declare (hide))</tt> is equivalent to <tt>(declare (block))</tt>.</p><h3 id="sec:bound-to-procedure"><a href="#sec:bound-to-procedure">bound-to-procedure</a></h3><pre>[declaration specifier] (bound-to-procedure IDENTIFIER ...)</pre><p>Declares that the given identifiers are always bound to procedure values.</p><h3 id="sec:enforce-argument-types"><a href="#sec:enforce-argument-types">enforce-argument-types</a></h3><pre>[declaration-specifier] (enforce-argument-types IDENTIFIER ...)</pre><p>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.</p><h3 id="sec:export"><a href="#sec:export">export</a></h3><pre>[declaration specifier] (export IDENTIFIER ...)</pre><p>The opposite of <tt>hide</tt>. All given identifiers will be exported and all toplevel variables not listed will be hidden and not be accessible outside of this compilation unit.</p><h3 id="sec:emit-external-prototypes-first"><a href="#sec:emit-external-prototypes-first">emit-external-prototypes-first</a></h3><pre>[declaration specifier] (emit-external-prototypes-first)</pre><p>Emit prototypes for callbacks defined with <tt>define-external</tt> before any other foreign declarations. Equivalent to giving the <tt>-emit-external-prototypes-first</tt> option to the compiler.</p><h3 id="sec:disable-interrupts"><a href="#sec:disable-interrupts">disable-interrupts</a></h3><pre>[declaration specifier] (disable-interrupts)</pre><p>Disable timer-interrupts checks in the compiled program. Threads can not be preempted in main- or library-units that contain this declaration.</p><h3 id="sec:emit-import-library"><a href="#sec:emit-import-library">emit-import-library</a></h3><pre>[declaration specifier] (emit-import-library MODULENAME | (MODULENAME FILENAME) ...)</pre><p>Declares that any following definition of a module named <tt>MODULENAME</tt> should be written to an external file (either a specified one or a file named <tt>&quot;MODULENAME.import.scm&quot;</tt>). The compiler option <tt>-emit-import-library</tt> may also be used instead.</p><p>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.</p><h3 id="sec:inline"><a href="#sec:inline">inline</a></h3><pre>[declaration specifier] (inline)
[declaration specifier] (not inline)
[declaration specifier] (inline IDENTIFIER ...)
[declaration specifier] (not inline IDENTIFIER ...)</pre><p>If given without an identifier-list, inlining of known procedures is enabled (this is equivalent to the <tt>-inline</tt> compiler option). When an identifier-list is given, then inlining is enabled only for the specified global procedures. The negated forms <tt>(not inline)</tt> and <tt>(not inline IDENTIFIER)</tt> disable global inlining, or inlining for the given global procedures only, respectively.</p><h3 id="sec:inline-global"><a href="#sec:inline-global">inline-global</a></h3><pre> [declaration specifier] (inline-global)
 [declaration specifier] (not inline-global)
 [declaration specifier] (inline-global IDENTIFIER ...)
 [declaration specifier] (not inline-global IDENTIFIER ...)</pre><p>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 <tt>&lt;source-filename&gt;.inline</tt> file in the current directory. Globally inlinable procedures from other compilation units referred to via <tt>(declare (uses ...))</tt> or <tt>require-extension</tt> are loaded from <tt>.inline</tt> files (if available in the current include path) and inlined in the current compilation unit.</p><p>Enabling global inlining implies <tt>(declare (inline))</tt>.</p><h3 id="sec:inline-limit"><a href="#sec:inline-limit">inline-limit</a></h3><pre>[declaration specifier] (inline-limit THRESHOLD)</pre><p>Sets the maximum size of procedures which may potentially be inlined. The default threshold is <tt>20</tt>.</p><h3 id="sec:unroll-limit"><a href="#sec:unroll-limit">unroll-limit</a></h3><pre>[declaration specifier] (unroll-limit LIMIT)</pre><p>Sets the maximum number of times a self-recursive call is inlined and so effectively &quot;unrolled&quot;. The default limit is 1.</p><h3 id="sec:keep-shadowed-macros"><a href="#sec:keep-shadowed-macros">keep-shadowed-macros</a></h3><pre>[declaration specifier] (keep-shadowed-macros)</pre><p>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.</p><h3 id="sec:local"><a href="#sec:local">local</a></h3><pre>[declaration specifier] (local)
[declaration specifier] (local IDENTIFIER ...)</pre><p>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 <tt>-local</tt> compiler option about the implications of this.</p><h3 id="sec:no-argc-checks"><a href="#sec:no-argc-checks">no-argc-checks</a></h3><pre>[declaration specifier] (no-argc-checks)</pre><p>Disables argument count checking.</p><h3 id="sec:no-bound-checks"><a href="#sec:no-bound-checks">no-bound-checks</a></h3><pre>[declaration specifier] (no-bound-checks)</pre><p>Disables the bound-checking of toplevel bindings.</p><h3 id="sec:no-procedure-checks"><a href="#sec:no-procedure-checks">no-procedure-checks</a></h3><pre>[declaration specifier] (no-procedure-checks)</pre><p>Disables checking of values in operator position for being of procedure type.</p><h3 id="sec:no-procedure-checks-for-usual-bindings"><a href="#sec:no-procedure-checks-for-usual-bindings">no-procedure-checks-for-usual-bindings</a></h3><pre>[declaration specifier] (no-procedure-checks-for-usual-bindings)</pre><p>Disables checking of procedures for the default standard- and extended toplevel bindings.</p><h3 id="sec:no-procedure-checks-for-toplevel-bindings"><a href="#sec:no-procedure-checks-for-toplevel-bindings">no-procedure-checks-for-toplevel-bindings</a></h3><pre>[declaration specifier] (no-procedure-checks-for-toplevel-bindings)</pre><p>Disables checking of procedures for calls to procedures referenced via a toplevel variable (calls to explicitly named procedures).</p><h3 id="sec:predicate"><a href="#sec:predicate">predicate</a></h3><pre>[declaration specifier] (predicate (IDENTIFIER TYPE) ...)</pre><p>Marks the global procedure <tt>IDENTIFIER</tt> as a predicate on <tt>TYPE</tt>.</p><h3 id="sec:profile"><a href="#sec:profile">profile</a></h3><pre>[declaration specifier] (profile IDENTIFIER ...)</pre><p>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.</p><h3 id="sec:pure"><a href="#sec:pure">pure</a></h3><pre>[declaration specifier] (pure IDENTIFIER ...)</pre><p>Declares the procedures with the names <tt>IDENTIFIER ...</tt> as referentially transparent, that is, as not having any side effects. This can help the compiler to remove non-side-effecting expressions.</p><h3 id="sec:number-type"><a href="#sec:number-type">number-type</a></h3><h3 id="sec:fixnum-arithmetic"><a href="#sec:fixnum-arithmetic">fixnum-arithmetic</a></h3><pre>[declaration specifier] ([number-type] TYPE)
[declaration specifier] (fixnum-arithmetic)</pre><p>Declares that only numbers of the given type are used. <tt>TYPE</tt> may be <tt>fixnum</tt> or <tt>generic</tt> (which is the default).</p><h3 id="sec:compile-syntax"><a href="#sec:compile-syntax">compile-syntax</a></h3><pre>[declaration specifier] (compile-syntax)</pre><p>Equivalent to the compiler option of the same name - macros defined in the compiled code are also made available at runtime.</p><h3 id="sec:safe-globals"><a href="#sec:safe-globals">safe-globals</a></h3><pre>[declaration specifier] (safe-globals)</pre><p>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.</p><h3 id="sec:specialize"><a href="#sec:specialize">specialize</a></h3><pre>[declaration specifier] (specialize)</pre><p>Enables specialization. This is equivalent to passing the <tt>-specialize</tt> option to the compiler.</p><h3 id="sec:standard-bindings"><a href="#sec:standard-bindings">standard-bindings</a></h3><pre>[declaration specifier] (standard-bindings IDENTIFIER ...)
[declaration specifier] (not standard-bindings IDENTIFIER ...)</pre><p>Declares that all given standard procedures (or all if no symbols are specified) are never globally redefined.  If <tt>not</tt> is specified, then all but the given standard bindings are assumed to be never redefined.</p><h3 id="sec:strict-types"><a href="#sec:strict-types">strict-types</a></h3><pre>[declaration specifier] (strict-types)</pre><p>Declares that the type of variables is not changed by assignment. Equivalent to giving the <tt>-strict-types</tt> compiler option.</p><h3 id="sec:type"><a href="#sec:type">type</a></h3><pre> [declaration specifier] (type (IDENTIFIER TYPE) ...)</pre><p>Declares toplevel procedures to have a specific type for scrutiny. <tt>IDENTIFIER</tt> should name a toplevel variable and <tt>TYPE</tt> should be a type specification.  A type-declaration overrides any previous declaration for the same identifier.  See also <a href="Types.html">Types</a> for more information about using types, the syntax of type-specifiers and a more convenient type-declaration syntax (<tt>:</tt>).</p><h3 id="sec:extended-bindings"><a href="#sec:extended-bindings">extended-bindings</a></h3><pre>[declaration specifier] (extended-bindings IDENTIFIER ...)
[declaration specifier] (not extended-bindings IDENTIFIER ...)</pre><p>Declares that all given non-standard and CHICKEN-specific procedures (or all if no symbols are specified) are never globally redefined. If <tt>not</tt> is specified, then all but the given extended bindings are assumed to be never redefined.</p><h3 id="sec:usual-integrations"><a href="#sec:usual-integrations">usual-integrations</a></h3><pre>[declaration specifier] (usual-integrations IDENTIFIER ...)
[declaration specifier] (not usual-integrations IDENTIFIER ...)</pre><p>Declares that all given standard and extended bindings (or all if no symbols are specified) are never globally redefined.  If <tt>not</tt> 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 <tt>-no-usual-integrations</tt> option has been given.</p><h3 id="sec:unit"><a href="#sec:unit">unit</a></h3><pre>[declaration specifier] (unit IDENTIFIER)</pre><p>Specify compilation unit-name (if this is a library)</p><h3 id="sec:unsafe"><a href="#sec:unsafe">unsafe</a></h3><pre>[declaration specifier] (unsafe)
[declaration specifier] (not safe)</pre><p>Do not generate safety-checks. This is the same as specifying the <tt>-unsafe</tt> option.  Also implies</p><pre>(declare (no-bound-checks) (no-procedure-checks) (no-argc-checks))</pre><h3 id="sec:unused"><a href="#sec:unused">unused</a></h3><pre>[declaration specifier] (unused IDENTIFIER ...)</pre><p>Disables any warnings when the global variable <tt>IDENTIFIER</tt> is not defined but used, or defined but never used and not exported.</p><h3 id="sec:uses"><a href="#sec:uses">uses</a></h3><pre>[declaration specifier] (uses IDENTIFIER ...)</pre><p>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 <tt>cond-expand</tt> knows about them.</p><hr /><p>Previous: <a href="Types.html">Types</a></p><p>Next: <a href="Extensions.html">Extensions</a></p></div></div></body>