Changeset c659968 for doc/papers/general
 Timestamp:
 Feb 8, 2018, 1:42:31 PM (6 years ago)
 Branches:
 ADT, aaronthesis, armeh, astexperimental, cleanupdtors, deferred_resn, demangler, enum, forallpointerdecay, jacob/cs343translation, jenkinssandbox, master, newast, newastuniqueexpr, newenv, no_list, persistentindexer, pthreademulation, qualifiedEnum, resolvnew, with_gc
 Children:
 eb7f20c
 Parents:
 77acd07d
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

doc/papers/general/Paper.tex
r77acd07d rc659968 1239 1239 In \CFA, the address of a @T&@ is a lvalue @T*@, as the address of the underlying @T@ is stored in the reference, and can thus be mutated there. 1240 1240 The result of this rule is that any reference can be rebound using the existing pointer assignment semantics by assigning a compatible pointer into the address of the reference, \eg @&r1 = &x;@ above. 1241 This rebinding can occur to an arbitrary depth of reference nesting; $n$ addressof operators applied to a reference nested $m$ times will produce an lvalue pointer nested $n$ times if $n \le m$ (note that $n = m+1$ is simply the usual C rvalue addressof operator applied to the $n = m$ case). 1242 The explicit addressof operators can be thought of as ``cancelling out'' the implicit dereference operators, \eg @(&`*`)r1 = &x@ or @(&(&`*`)`*`)r3 = &(&`*`)r1@ or even @(&`*`)r2 = (&`*`)`*`r3@ for @&r2 = &r3@. 1241 This rebinding can occur to an arbitrary depth of reference nesting; loosely speaking, nested addressof operators will produce an lvalue nested pointer up to as deep as the reference they're applied to. 1242 These explicit addressof operators can be thought of as ``cancelling out'' the implicit dereference operators, \eg @(&`*`)r1 = &x@ or @(&(&`*`)`*`)r3 = &(&`*`)r1@ or even @(&`*`)r2 = (&`*`)`*`r3@ for @&r2 = &r3@. 1243 More precisely: 1244 \begin{itemize} 1245 \item 1246 if @R@ is an rvalue of type {@T &@$_1 \cdots$@ &@$_r$} where $r \ge 1$ references (@&@ symbols) than @&R@ has type {@T `*`&@$_{\color{red}2} \cdots$@ &@$_{\color{red}r}$}, \\ \ie @T@ pointer with $r1$ references (@&@ symbols). 1247 1248 \item 1249 if @L@ is an lvalue of type {@T &@$_1 \cdots$@ &@$_l$} where $l \ge 0$ references (@&@ symbols) then @&L@ has type {@T `*`&@$_{\color{red}1} \cdots$@ &@$_{\color{red}l}$}, \\ \ie @T@ pointer with $l$ references (@&@ symbols). 1250 \end{itemize} 1243 1251 1244 1252 Since pointers and references share the same internal representation, code using either is equally performant; in fact the \CFA compiler converts references to pointers internally, and the choice between them in user code can be made based solely on convenience. … … 1275 1283 In particular, \CFA does not implement classbased encapsulation: neither the constructor nor any other function has privileged access to the implementation details of a type, except through the translationunitscope method of opaque structs provided by C. 1276 1284 1277 In \CFA, a constructor is a function named @?{}@, while a destructor is a function named @^?{}@; like other \CFA operators, these names represent the syntax used to call the constructor or destructor, \eg @ S s = { ... };@ or @^(s){};@.1285 In \CFA, a constructor is a function named @?{}@, while a destructor is a function named @^?{}@; like other \CFA operators, these names represent the syntax used to call the constructor or destructor, \eg @x{ ... };@ or @^x{};@. 1278 1286 Every constructor and destructor must have a return type of @void@, and its first parameter must have a reference type whose base type is the type of the object the function constructs or destructs. 1279 1287 This first parameter is informally called the @this@ parameter, as in many objectoriented languages, though a programmer may give it an arbitrary name. … … 1328 1336 \begin{cfa} 1329 1337 Array a, b; 1330 (a){};$\C{// default construct}$1331 (b){ a }; $\C{// copy construct}$1332 ^ (a){};$\C{// destruct}$1333 (a){ 5, 0xFFFFFFFF }; $\C{// explicit constructor call}$1338 a{}; $\C{// default construct}$ 1339 b{ a }; $\C{// copy construct}$ 1340 ^a{}; $\C{// destruct}$ 1341 a{ 5, 0xFFFFFFFF }; $\C{// explicit constructor call}$ 1334 1342 \end{cfa} 1335 1343
Note: See TracChangeset
for help on using the changeset viewer.