xref: /minix3/external/bsd/llvm/dist/clang/docs/BlockLanguageSpec.rst (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc
2*f4a2713aSLionel Sambuc.. role:: block-term
3*f4a2713aSLionel Sambuc
4*f4a2713aSLionel Sambuc=================================
5*f4a2713aSLionel SambucLanguage Specification for Blocks
6*f4a2713aSLionel Sambuc=================================
7*f4a2713aSLionel Sambuc
8*f4a2713aSLionel Sambuc.. contents::
9*f4a2713aSLionel Sambuc   :local:
10*f4a2713aSLionel Sambuc
11*f4a2713aSLionel SambucRevisions
12*f4a2713aSLionel Sambuc=========
13*f4a2713aSLionel Sambuc
14*f4a2713aSLionel Sambuc- 2008/2/25 --- created
15*f4a2713aSLionel Sambuc- 2008/7/28 --- revised, ``__block`` syntax
16*f4a2713aSLionel Sambuc- 2008/8/13 --- revised, Block globals
17*f4a2713aSLionel Sambuc- 2008/8/21 --- revised, C++ elaboration
18*f4a2713aSLionel Sambuc- 2008/11/1 --- revised, ``__weak`` support
19*f4a2713aSLionel Sambuc- 2009/1/12 --- revised, explicit return types
20*f4a2713aSLionel Sambuc- 2009/2/10 --- revised, ``__block`` objects need retain
21*f4a2713aSLionel Sambuc
22*f4a2713aSLionel SambucOverview
23*f4a2713aSLionel Sambuc========
24*f4a2713aSLionel Sambuc
25*f4a2713aSLionel SambucA new derived type is introduced to C and, by extension, Objective-C,
26*f4a2713aSLionel SambucC++, and Objective-C++
27*f4a2713aSLionel Sambuc
28*f4a2713aSLionel SambucThe Block Type
29*f4a2713aSLionel Sambuc==============
30*f4a2713aSLionel Sambuc
31*f4a2713aSLionel SambucLike function types, the :block-term:`Block type` is a pair consisting
32*f4a2713aSLionel Sambucof a result value type and a list of parameter types very similar to a
33*f4a2713aSLionel Sambucfunction type. Blocks are intended to be used much like functions with
34*f4a2713aSLionel Sambucthe key distinction being that in addition to executable code they
35*f4a2713aSLionel Sambucalso contain various variable bindings to automatic (stack) or managed
36*f4a2713aSLionel Sambuc(heap) memory.
37*f4a2713aSLionel Sambuc
38*f4a2713aSLionel SambucThe abstract declarator,
39*f4a2713aSLionel Sambuc
40*f4a2713aSLionel Sambuc.. code-block:: c
41*f4a2713aSLionel Sambuc
42*f4a2713aSLionel Sambuc   int (^)(char, float)
43*f4a2713aSLionel Sambuc
44*f4a2713aSLionel Sambucdescribes a reference to a Block that, when invoked, takes two
45*f4a2713aSLionel Sambucparameters, the first of type char and the second of type float, and
46*f4a2713aSLionel Sambucreturns a value of type int.  The Block referenced is of opaque data
47*f4a2713aSLionel Sambucthat may reside in automatic (stack) memory, global memory, or heap
48*f4a2713aSLionel Sambucmemory.
49*f4a2713aSLionel Sambuc
50*f4a2713aSLionel SambucBlock Variable Declarations
51*f4a2713aSLionel Sambuc===========================
52*f4a2713aSLionel Sambuc
53*f4a2713aSLionel SambucA :block-term:`variable with Block type` is declared using function
54*f4a2713aSLionel Sambucpointer style notation substituting ``^`` for ``*``. The following are
55*f4a2713aSLionel Sambucvalid Block variable declarations:
56*f4a2713aSLionel Sambuc
57*f4a2713aSLionel Sambuc.. code-block:: c
58*f4a2713aSLionel Sambuc
59*f4a2713aSLionel Sambuc    void (^blockReturningVoidWithVoidArgument)(void);
60*f4a2713aSLionel Sambuc    int (^blockReturningIntWithIntAndCharArguments)(int, char);
61*f4a2713aSLionel Sambuc    void (^arrayOfTenBlocksReturningVoidWithIntArgument[10])(int);
62*f4a2713aSLionel Sambuc
63*f4a2713aSLionel SambucVariadic ``...`` arguments are supported. [variadic.c] A Block that
64*f4a2713aSLionel Sambuctakes no arguments must specify void in the argument list [voidarg.c].
65*f4a2713aSLionel SambucAn empty parameter list does not represent, as K&R provide, an
66*f4a2713aSLionel Sambucunspecified argument list.  Note: both gcc and clang support K&R style
67*f4a2713aSLionel Sambucas a convenience.
68*f4a2713aSLionel Sambuc
69*f4a2713aSLionel SambucA Block reference may be cast to a pointer of arbitrary type and vice
70*f4a2713aSLionel Sambucversa. [cast.c] A Block reference may not be dereferenced via the
71*f4a2713aSLionel Sambucpointer dereference operator ``*``, and thus a Block's size may not be
72*f4a2713aSLionel Sambuccomputed at compile time. [sizeof.c]
73*f4a2713aSLionel Sambuc
74*f4a2713aSLionel SambucBlock Literal Expressions
75*f4a2713aSLionel Sambuc=========================
76*f4a2713aSLionel Sambuc
77*f4a2713aSLionel SambucA :block-term:`Block literal expression` produces a reference to a
78*f4a2713aSLionel SambucBlock. It is introduced by the use of the ``^`` token as a unary
79*f4a2713aSLionel Sambucoperator.
80*f4a2713aSLionel Sambuc
81*f4a2713aSLionel Sambuc.. code-block:: c
82*f4a2713aSLionel Sambuc
83*f4a2713aSLionel Sambuc    Block_literal_expression ::=   ^ block_decl compound_statement_body
84*f4a2713aSLionel Sambuc    block_decl ::=
85*f4a2713aSLionel Sambuc    block_decl ::= parameter_list
86*f4a2713aSLionel Sambuc    block_decl ::= type_expression
87*f4a2713aSLionel Sambuc
88*f4a2713aSLionel Sambucwhere type expression is extended to allow ``^`` as a Block reference
89*f4a2713aSLionel Sambuc(pointer) where ``*`` is allowed as a function reference (pointer).
90*f4a2713aSLionel Sambuc
91*f4a2713aSLionel SambucThe following Block literal:
92*f4a2713aSLionel Sambuc
93*f4a2713aSLionel Sambuc.. code-block:: c
94*f4a2713aSLionel Sambuc
95*f4a2713aSLionel Sambuc    ^ void (void) { printf("hello world\n"); }
96*f4a2713aSLionel Sambuc
97*f4a2713aSLionel Sambucproduces a reference to a Block with no arguments with no return value.
98*f4a2713aSLionel Sambuc
99*f4a2713aSLionel SambucThe return type is optional and is inferred from the return
100*f4a2713aSLionel Sambucstatements. If the return statements return a value, they all must
101*f4a2713aSLionel Sambucreturn a value of the same type. If there is no value returned the
102*f4a2713aSLionel Sambucinferred type of the Block is void; otherwise it is the type of the
103*f4a2713aSLionel Sambucreturn statement value.
104*f4a2713aSLionel Sambuc
105*f4a2713aSLionel SambucIf the return type is omitted and the argument list is ``( void )``,
106*f4a2713aSLionel Sambucthe ``( void )`` argument list may also be omitted.
107*f4a2713aSLionel Sambuc
108*f4a2713aSLionel SambucSo:
109*f4a2713aSLionel Sambuc
110*f4a2713aSLionel Sambuc.. code-block:: c
111*f4a2713aSLionel Sambuc
112*f4a2713aSLionel Sambuc    ^ ( void ) { printf("hello world\n"); }
113*f4a2713aSLionel Sambuc
114*f4a2713aSLionel Sambucand:
115*f4a2713aSLionel Sambuc
116*f4a2713aSLionel Sambuc.. code-block:: c
117*f4a2713aSLionel Sambuc
118*f4a2713aSLionel Sambuc    ^ { printf("hello world\n"); }
119*f4a2713aSLionel Sambuc
120*f4a2713aSLionel Sambucare exactly equivalent constructs for the same expression.
121*f4a2713aSLionel Sambuc
122*f4a2713aSLionel SambucThe type_expression extends C expression parsing to accommodate Block
123*f4a2713aSLionel Sambucreference declarations as it accommodates function pointer
124*f4a2713aSLionel Sambucdeclarations.
125*f4a2713aSLionel Sambuc
126*f4a2713aSLionel SambucGiven:
127*f4a2713aSLionel Sambuc
128*f4a2713aSLionel Sambuc.. code-block:: c
129*f4a2713aSLionel Sambuc
130*f4a2713aSLionel Sambuc    typedef int (*pointerToFunctionThatReturnsIntWithCharArg)(char);
131*f4a2713aSLionel Sambuc    pointerToFunctionThatReturnsIntWithCharArg functionPointer;
132*f4a2713aSLionel Sambuc    ^ pointerToFunctionThatReturnsIntWithCharArg (float x) { return functionPointer; }
133*f4a2713aSLionel Sambuc
134*f4a2713aSLionel Sambucand:
135*f4a2713aSLionel Sambuc
136*f4a2713aSLionel Sambuc.. code-block:: c
137*f4a2713aSLionel Sambuc
138*f4a2713aSLionel Sambuc    ^ int ((*)(float x))(char) { return functionPointer; }
139*f4a2713aSLionel Sambuc
140*f4a2713aSLionel Sambucare equivalent expressions, as is:
141*f4a2713aSLionel Sambuc
142*f4a2713aSLionel Sambuc.. code-block:: c
143*f4a2713aSLionel Sambuc
144*f4a2713aSLionel Sambuc    ^(float x) { return functionPointer; }
145*f4a2713aSLionel Sambuc
146*f4a2713aSLionel Sambuc[returnfunctionptr.c]
147*f4a2713aSLionel Sambuc
148*f4a2713aSLionel SambucThe compound statement body establishes a new lexical scope within
149*f4a2713aSLionel Sambucthat of its parent. Variables used within the scope of the compound
150*f4a2713aSLionel Sambucstatement are bound to the Block in the normal manner with the
151*f4a2713aSLionel Sambucexception of those in automatic (stack) storage. Thus one may access
152*f4a2713aSLionel Sambucfunctions and global variables as one would expect, as well as static
153*f4a2713aSLionel Sambuclocal variables. [testme]
154*f4a2713aSLionel Sambuc
155*f4a2713aSLionel SambucLocal automatic (stack) variables referenced within the compound
156*f4a2713aSLionel Sambucstatement of a Block are imported and captured by the Block as const
157*f4a2713aSLionel Sambuccopies. The capture (binding) is performed at the time of the Block
158*f4a2713aSLionel Sambucliteral expression evaluation.
159*f4a2713aSLionel Sambuc
160*f4a2713aSLionel SambucThe compiler is not required to capture a variable if it can prove
161*f4a2713aSLionel Sambucthat no references to the variable will actually be evaluated.
162*f4a2713aSLionel SambucProgrammers can force a variable to be captured by referencing it in a
163*f4a2713aSLionel Sambucstatement at the beginning of the Block, like so:
164*f4a2713aSLionel Sambuc
165*f4a2713aSLionel Sambuc.. code-block:: c
166*f4a2713aSLionel Sambuc
167*f4a2713aSLionel Sambuc  (void) foo;
168*f4a2713aSLionel Sambuc
169*f4a2713aSLionel SambucThis matters when capturing the variable has side-effects, as it can
170*f4a2713aSLionel Sambucin Objective-C or C++.
171*f4a2713aSLionel Sambuc
172*f4a2713aSLionel SambucThe lifetime of variables declared in a Block is that of a function;
173*f4a2713aSLionel Sambuceach activation frame contains a new copy of variables declared within
174*f4a2713aSLionel Sambucthe local scope of the Block. Such variable declarations should be
175*f4a2713aSLionel Sambucallowed anywhere [testme] rather than only when C99 parsing is
176*f4a2713aSLionel Sambucrequested, including for statements. [testme]
177*f4a2713aSLionel Sambuc
178*f4a2713aSLionel SambucBlock literal expressions may occur within Block literal expressions
179*f4a2713aSLionel Sambuc(nest) and all variables captured by any nested blocks are implicitly
180*f4a2713aSLionel Sambucalso captured in the scopes of their enclosing Blocks.
181*f4a2713aSLionel Sambuc
182*f4a2713aSLionel SambucA Block literal expression may be used as the initialization value for
183*f4a2713aSLionel SambucBlock variables at global or local static scope.
184*f4a2713aSLionel Sambuc
185*f4a2713aSLionel SambucThe Invoke Operator
186*f4a2713aSLionel Sambuc===================
187*f4a2713aSLionel Sambuc
188*f4a2713aSLionel SambucBlocks are :block-term:`invoked` using function call syntax with a
189*f4a2713aSLionel Sambuclist of expression parameters of types corresponding to the
190*f4a2713aSLionel Sambucdeclaration and returning a result type also according to the
191*f4a2713aSLionel Sambucdeclaration. Given:
192*f4a2713aSLionel Sambuc
193*f4a2713aSLionel Sambuc.. code-block:: c
194*f4a2713aSLionel Sambuc
195*f4a2713aSLionel Sambuc    int (^x)(char);
196*f4a2713aSLionel Sambuc    void (^z)(void);
197*f4a2713aSLionel Sambuc    int (^(*y))(char) = &x;
198*f4a2713aSLionel Sambuc
199*f4a2713aSLionel Sambucthe following are all legal Block invocations:
200*f4a2713aSLionel Sambuc
201*f4a2713aSLionel Sambuc.. code-block:: c
202*f4a2713aSLionel Sambuc
203*f4a2713aSLionel Sambuc    x('a');
204*f4a2713aSLionel Sambuc    (*y)('a');
205*f4a2713aSLionel Sambuc    (true ? x : *y)('a')
206*f4a2713aSLionel Sambuc
207*f4a2713aSLionel SambucThe Copy and Release Operations
208*f4a2713aSLionel Sambuc===============================
209*f4a2713aSLionel Sambuc
210*f4a2713aSLionel SambucThe compiler and runtime provide :block-term:`copy` and
211*f4a2713aSLionel Sambuc:block-term:`release` operations for Block references that create and,
212*f4a2713aSLionel Sambucin matched use, release allocated storage for referenced Blocks.
213*f4a2713aSLionel Sambuc
214*f4a2713aSLionel SambucThe copy operation ``Block_copy()`` is styled as a function that takes
215*f4a2713aSLionel Sambucan arbitrary Block reference and returns a Block reference of the same
216*f4a2713aSLionel Sambuctype. The release operation, ``Block_release()``, is styled as a
217*f4a2713aSLionel Sambucfunction that takes an arbitrary Block reference and, if dynamically
218*f4a2713aSLionel Sambucmatched to a Block copy operation, allows recovery of the referenced
219*f4a2713aSLionel Sambucallocated memory.
220*f4a2713aSLionel Sambuc
221*f4a2713aSLionel Sambuc
222*f4a2713aSLionel SambucThe ``__block`` Storage Qualifier
223*f4a2713aSLionel Sambuc=================================
224*f4a2713aSLionel Sambuc
225*f4a2713aSLionel SambucIn addition to the new Block type we also introduce a new storage
226*f4a2713aSLionel Sambucqualifier, :block-term:`__block`, for local variables. [testme: a
227*f4a2713aSLionel Sambuc__block declaration within a block literal] The ``__block`` storage
228*f4a2713aSLionel Sambucqualifier is mutually exclusive to the existing local storage
229*f4a2713aSLionel Sambucqualifiers auto, register, and static. [testme] Variables qualified by
230*f4a2713aSLionel Sambuc``__block`` act as if they were in allocated storage and this storage
231*f4a2713aSLionel Sambucis automatically recovered after last use of said variable.  An
232*f4a2713aSLionel Sambucimplementation may choose an optimization where the storage is
233*f4a2713aSLionel Sambucinitially automatic and only "moved" to allocated (heap) storage upon
234*f4a2713aSLionel Sambuca Block_copy of a referencing Block.  Such variables may be mutated as
235*f4a2713aSLionel Sambucnormal variables are.
236*f4a2713aSLionel Sambuc
237*f4a2713aSLionel SambucIn the case where a ``__block`` variable is a Block one must assume
238*f4a2713aSLionel Sambucthat the ``__block`` variable resides in allocated storage and as such
239*f4a2713aSLionel Sambucis assumed to reference a Block that is also in allocated storage
240*f4a2713aSLionel Sambuc(that it is the result of a ``Block_copy`` operation).  Despite this
241*f4a2713aSLionel Sambucthere is no provision to do a ``Block_copy`` or a ``Block_release`` if
242*f4a2713aSLionel Sambucan implementation provides initial automatic storage for Blocks.  This
243*f4a2713aSLionel Sambucis due to the inherent race condition of potentially several threads
244*f4a2713aSLionel Sambuctrying to update the shared variable and the need for synchronization
245*f4a2713aSLionel Sambucaround disposing of older values and copying new ones.  Such
246*f4a2713aSLionel Sambucsynchronization is beyond the scope of this language specification.
247*f4a2713aSLionel Sambuc
248*f4a2713aSLionel Sambuc
249*f4a2713aSLionel SambucControl Flow
250*f4a2713aSLionel Sambuc============
251*f4a2713aSLionel Sambuc
252*f4a2713aSLionel SambucThe compound statement of a Block is treated much like a function body
253*f4a2713aSLionel Sambucwith respect to control flow in that goto, break, and continue do not
254*f4a2713aSLionel Sambucescape the Block.  Exceptions are treated *normally* in that when
255*f4a2713aSLionel Sambucthrown they pop stack frames until a catch clause is found.
256*f4a2713aSLionel Sambuc
257*f4a2713aSLionel Sambuc
258*f4a2713aSLionel SambucObjective-C Extensions
259*f4a2713aSLionel Sambuc======================
260*f4a2713aSLionel Sambuc
261*f4a2713aSLionel SambucObjective-C extends the definition of a Block reference type to be
262*f4a2713aSLionel Sambucthat also of id.  A variable or expression of Block type may be
263*f4a2713aSLionel Sambucmessaged or used as a parameter wherever an id may be. The converse is
264*f4a2713aSLionel Sambucalso true. Block references may thus appear as properties and are
265*f4a2713aSLionel Sambucsubject to the assign, retain, and copy attribute logic that is
266*f4a2713aSLionel Sambucreserved for objects.
267*f4a2713aSLionel Sambuc
268*f4a2713aSLionel SambucAll Blocks are constructed to be Objective-C objects regardless of
269*f4a2713aSLionel Sambucwhether the Objective-C runtime is operational in the program or
270*f4a2713aSLionel Sambucnot. Blocks using automatic (stack) memory are objects and may be
271*f4a2713aSLionel Sambucmessaged, although they may not be assigned into ``__weak`` locations
272*f4a2713aSLionel Sambucif garbage collection is enabled.
273*f4a2713aSLionel Sambuc
274*f4a2713aSLionel SambucWithin a Block literal expression within a method definition
275*f4a2713aSLionel Sambucreferences to instance variables are also imported into the lexical
276*f4a2713aSLionel Sambucscope of the compound statement. These variables are implicitly
277*f4a2713aSLionel Sambucqualified as references from self, and so self is imported as a const
278*f4a2713aSLionel Sambuccopy. The net effect is that instance variables can be mutated.
279*f4a2713aSLionel Sambuc
280*f4a2713aSLionel SambucThe :block-term:`Block_copy` operator retains all objects held in
281*f4a2713aSLionel Sambucvariables of automatic storage referenced within the Block expression
282*f4a2713aSLionel Sambuc(or form strong references if running under garbage collection).
283*f4a2713aSLionel SambucObject variables of ``__block`` storage type are assumed to hold
284*f4a2713aSLionel Sambucnormal pointers with no provision for retain and release messages.
285*f4a2713aSLionel Sambuc
286*f4a2713aSLionel SambucFoundation defines (and supplies) ``-copy`` and ``-release`` methods for
287*f4a2713aSLionel SambucBlocks.
288*f4a2713aSLionel Sambuc
289*f4a2713aSLionel SambucIn the Objective-C and Objective-C++ languages, we allow the
290*f4a2713aSLionel Sambuc``__weak`` specifier for ``__block`` variables of object type.  If
291*f4a2713aSLionel Sambucgarbage collection is not enabled, this qualifier causes these
292*f4a2713aSLionel Sambucvariables to be kept without retain messages being sent. This
293*f4a2713aSLionel Sambucknowingly leads to dangling pointers if the Block (or a copy) outlives
294*f4a2713aSLionel Sambucthe lifetime of this object.
295*f4a2713aSLionel Sambuc
296*f4a2713aSLionel SambucIn garbage collected environments, the ``__weak`` variable is set to
297*f4a2713aSLionel Sambucnil when the object it references is collected, as long as the
298*f4a2713aSLionel Sambuc``__block`` variable resides in the heap (either by default or via
299*f4a2713aSLionel Sambuc``Block_copy()``).  The initial Apple implementation does in fact
300*f4a2713aSLionel Sambucstart ``__block`` variables on the stack and migrate them to the heap
301*f4a2713aSLionel Sambuconly as a result of a ``Block_copy()`` operation.
302*f4a2713aSLionel Sambuc
303*f4a2713aSLionel SambucIt is a runtime error to attempt to assign a reference to a
304*f4a2713aSLionel Sambucstack-based Block into any storage marked ``__weak``, including
305*f4a2713aSLionel Sambuc``__weak`` ``__block`` variables.
306*f4a2713aSLionel Sambuc
307*f4a2713aSLionel Sambuc
308*f4a2713aSLionel SambucC++ Extensions
309*f4a2713aSLionel Sambuc==============
310*f4a2713aSLionel Sambuc
311*f4a2713aSLionel SambucBlock literal expressions within functions are extended to allow const
312*f4a2713aSLionel Sambucuse of C++ objects, pointers, or references held in automatic storage.
313*f4a2713aSLionel Sambuc
314*f4a2713aSLionel SambucAs usual, within the block, references to captured variables become
315*f4a2713aSLionel Sambucconst-qualified, as if they were references to members of a const
316*f4a2713aSLionel Sambucobject.  Note that this does not change the type of a variable of
317*f4a2713aSLionel Sambucreference type.
318*f4a2713aSLionel Sambuc
319*f4a2713aSLionel SambucFor example, given a class Foo:
320*f4a2713aSLionel Sambuc
321*f4a2713aSLionel Sambuc.. code-block:: c
322*f4a2713aSLionel Sambuc
323*f4a2713aSLionel Sambuc      Foo foo;
324*f4a2713aSLionel Sambuc      Foo &fooRef = foo;
325*f4a2713aSLionel Sambuc      Foo *fooPtr = &foo;
326*f4a2713aSLionel Sambuc
327*f4a2713aSLionel SambucA Block that referenced these variables would import the variables as
328*f4a2713aSLionel Sambucconst variations:
329*f4a2713aSLionel Sambuc
330*f4a2713aSLionel Sambuc.. code-block:: c
331*f4a2713aSLionel Sambuc
332*f4a2713aSLionel Sambuc      const Foo block_foo = foo;
333*f4a2713aSLionel Sambuc      Foo &block_fooRef = fooRef;
334*f4a2713aSLionel Sambuc      Foo *const block_fooPtr = fooPtr;
335*f4a2713aSLionel Sambuc
336*f4a2713aSLionel SambucCaptured variables are copied into the Block at the instant of
337*f4a2713aSLionel Sambucevaluating the Block literal expression.  They are also copied when
338*f4a2713aSLionel Sambuccalling ``Block_copy()`` on a Block allocated on the stack.  In both
339*f4a2713aSLionel Sambuccases, they are copied as if the variable were const-qualified, and
340*f4a2713aSLionel Sambucit's an error if there's no such constructor.
341*f4a2713aSLionel Sambuc
342*f4a2713aSLionel SambucCaptured variables in Blocks on the stack are destroyed when control
343*f4a2713aSLionel Sambucleaves the compound statement that contains the Block literal
344*f4a2713aSLionel Sambucexpression.  Captured variables in Blocks on the heap are destroyed
345*f4a2713aSLionel Sambucwhen the reference count of the Block drops to zero.
346*f4a2713aSLionel Sambuc
347*f4a2713aSLionel SambucVariables declared as residing in ``__block`` storage may be initially
348*f4a2713aSLionel Sambucallocated in the heap or may first appear on the stack and be copied
349*f4a2713aSLionel Sambucto the heap as a result of a ``Block_copy()`` operation. When copied
350*f4a2713aSLionel Sambucfrom the stack, ``__block`` variables are copied using their normal
351*f4a2713aSLionel Sambucqualification (i.e. without adding const).  In C++11, ``__block``
352*f4a2713aSLionel Sambucvariables are copied as x-values if that is possible, then as l-values
353*f4a2713aSLionel Sambucif not; if both fail, it's an error.  The destructor for any initial
354*f4a2713aSLionel Sambucstack-based version is called at the variable's normal end of scope.
355*f4a2713aSLionel Sambuc
356*f4a2713aSLionel SambucReferences to ``this``, as well as references to non-static members of
357*f4a2713aSLionel Sambucany enclosing class, are evaluated by capturing ``this`` just like a
358*f4a2713aSLionel Sambucnormal variable of C pointer type.
359*f4a2713aSLionel Sambuc
360*f4a2713aSLionel SambucMember variables that are Blocks may not be overloaded by the types of
361*f4a2713aSLionel Sambuctheir arguments.
362