Lines Matching full:block

2 .. role:: block-term
16 - 2008/8/13 --- revised, Block globals
28 The Block Type
31 Like function types, the :block-term:`Block type` is a pair consisting
40 .. code-block:: c
44 describes a reference to a Block that, when invoked, takes two
46 returns a value of type int. The Block referenced is of opaque data
50 Block Variable Declarations
53 A :block-term:`variable with Block type` is declared using function
55 valid Block variable declarations:
57 .. code-block:: c
63 Variadic ``...`` arguments are supported. [variadic.c] A Block that
69 A Block reference may be cast to a pointer of arbitrary type and vice
70 versa. [cast.c] A Block reference may not be dereferenced via the
71 pointer dereference operator ``*``, and thus a Block's size may not be
74 Block Literal Expressions
77 A :block-term:`Block literal expression` produces a reference to a
78 Block. It is introduced by the use of the ``^`` token as a unary
81 .. code-block:: c
88 where type expression is extended to allow ``^`` as a Block reference
91 The following Block literal:
93 .. code-block:: c
97 produces a reference to a Block with no arguments with no return value.
102 inferred type of the Block is void; otherwise it is the type of the
110 .. code-block:: c
116 .. code-block:: c
122 The type_expression extends C expression parsing to accommodate Block
128 .. code-block:: c
136 .. code-block:: c
142 .. code-block:: c
150 statement are bound to the Block in the normal manner with the
156 statement of a Block are imported and captured by the Block as const
157 copies. The capture (binding) is performed at the time of the Block
163 statement at the beginning of the Block, like so:
165 .. code-block:: c
172 The lifetime of variables declared in a Block is that of a function;
174 the local scope of the Block. Such variable declarations should be
178 Block literal expressions may occur within Block literal expressions
182 A Block literal expression may be used as the initialization value for
183 Block variables at global or local static scope.
188 Blocks are :block-term:`invoked` using function call syntax with a
193 .. code-block:: c
199 the following are all legal Block invocations:
201 .. code-block:: c
210 The compiler and runtime provide :block-term:`copy` and
211 :block-term:`release` operations for Block references that create and,
215 an arbitrary Block reference and returns a Block reference of the same
217 function that takes an arbitrary Block reference and, if dynamically
218 matched to a Block copy operation, allows recovery of the referenced
225 In addition to the new Block type we also introduce a new storage
226 qualifier, :block-term:`__block`, for local variables. [testme: a
227 __block declaration within a block literal] The ``__block`` storage
234 a Block_copy of a referencing Block. Such variables may be mutated as
237 In the case where a ``__block`` variable is a Block one must assume
239 is assumed to reference a Block that is also in allocated storage
252 The compound statement of a Block is treated much like a function body
254 escape the Block. Exceptions are treated *normally* in that when
261 Objective-C extends the definition of a Block reference type to be
262 that also of id. A variable or expression of Block type may be
264 also true. Block references may thus appear as properties and are
274 Within a Block literal expression within a method definition
280 The :block-term:`Block_copy` operator retains all objects held in
281 variables of automatic storage referenced within the Block expression
293 knowingly leads to dangling pointers if the Block (or a copy) outlives
304 stack-based Block into any storage marked ``__weak``, including
311 Block literal expressions within functions are extended to allow const
314 As usual, within the block, references to captured variables become
321 .. code-block:: c
327 A Block that referenced these variables would import the variables as
330 .. code-block:: c
336 Captured variables are copied into the Block at the instant of
337 evaluating the Block literal expression. They are also copied when
338 calling ``Block_copy()`` on a Block allocated on the stack. In both
343 leaves the compound statement that contains the Block literal
345 when the reference count of the Block drops to zero.