Changeset d893266a
- Timestamp:
- Mar 6, 2018, 3:43:42 PM (7 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- 520145b
- Parents:
- ea46db7
- Location:
- doc
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified doc/bibliography/pl.bib ¶
rea46db7 rd893266a 1439 1439 contributer = {pabuhr@plg}, 1440 1440 author = {Peter A. Buhr}, 1441 title = {$\mu${C}{\kern-.1em\hbox{\large\texttt{+\kern-.25em+}}} Annotated Reference Manual, Version 6.1.0},1441 title = {$\mu${C}{\kern-.1em\hbox{\large\texttt{+\kern-.25em+}}} Annotated Reference Manual, Version 7.0.0}, 1442 1442 institution = {School of Computer Science, University of Waterloo}, 1443 1443 address = {Waterloo, Ontario, Canada, N2L 3G1}, 1444 month = jul,1445 year = 201 5,1446 note = {\href{http://plg.uwaterloo.ca/~usystem/pub/uSystem/u++- 6.1.0.sh}{http://\-plg.\-uwaterloo.\-ca/\-$\sim$usystem/\-pub/\-uSystem/\-u++-6.1.0.sh}},1444 month = dec, 1445 year = 2017, 1446 note = {\href{http://plg.uwaterloo.ca/~usystem/pub/uSystem/u++-7.0.0.sh}{http://\-plg.\-uwaterloo.\-ca/\-$\sim$usystem/\-pub/\-uSystem/\-u++-7.0.0.sh}}, 1447 1447 } 1448 1448 -
TabularUnified doc/papers/general/Paper.tex ¶
rea46db7 rd893266a 58 58 \setlength{\parindentlnth}{\parindent} 59 59 60 \newcommand{\LstBasicStyle}[1]{{\lst@basicstyle{\lst@basicstyle{#1}}}} 60 61 \newcommand{\LstKeywordStyle}[1]{{\lst@basicstyle{\lst@keywordstyle{#1}}}} 61 62 \newcommand{\LstCommentStyle}[1]{{\lst@basicstyle{\lst@commentstyle{#1}}}} … … 231 232 All of the features discussed in this paper are working, unless a feature states it is a future feature for completion. 232 233 234 Finally, it is impossible to describe a programming language without usages before definitions. 235 Therefore, syntax and semantics appear before explanations; 236 hence, patience is necessary until details are presented. 237 233 238 234 239 \section{Polymorphic Functions} … … 263 268 \end{cfa} 264 269 \CFA maximizes the ability to reuse names to aggressively address the naming problem. 265 In some cases, hundreds of names can be reduced to tens, resulting in a significant cognitive reduction for a programmer.270 In some cases, hundreds of names can be reduced to tens, resulting in a significant cognitive reduction. 266 271 In the above, the name @max@ has a consistent meaning, and a programmer only needs to remember the single concept: maximum. 267 272 To prevent significant ambiguities, \CFA uses the return type in selecting overloads, \eg in the assignment to @m@, the compiler use @m@'s type to unambiguously select the most appropriate call to function @max@ (as does Ada). 268 273 As is shown later, there are a number of situations where \CFA takes advantage of available type information to disambiguate, where other programming languages generate ambiguities. 269 274 270 \Celeven added @_Generic@ expressions, which can be used in preprocessor macros to provide a form of ad-hoc polymorphism; however, this polymorphism is both functionally and ergonomically inferior to \CFA name overloading. 271 The macro wrapping the generic expression imposes some limitations; as an example, it could not implement the example above, because the variables @max@ would collide with the functions @max@. 272 Ergonomic limitations of @_Generic@ include the necessity to put a fixed list of supported types in a single place and manually dispatch to appropriate overloads, as well as possible namespace pollution from the functions dispatched to, which must all have distinct names. 273 Though name-overloading removes a major use-case for @_Generic@ expressions, \CFA implements @_Generic@ for backwards-compatibility purposes. \TODO{actually implement that} 275 \Celeven added @_Generic@ expressions, which is used in preprocessor macros to provide a form of ad-hoc polymorphism; 276 however, this polymorphism is both functionally and ergonomically inferior to \CFA name overloading. 277 The macro wrapping the generic expression imposes some limitations; 278 \eg, it cannot implement the example above, because the variables @max@ are ambiguous with the functions @max@. 279 Ergonomic limitations of @_Generic@ include the necessity to put a fixed list of supported types in a single place and manually dispatch to appropriate overloads, as well as possible namespace pollution from the dispatch functions, which must all have distinct names. 280 For backwards compatibility, \CFA supports @_Generic@ expressions, but it is an unnecessary mechanism. \TODO{actually implement that} 274 281 275 282 % http://fanf.livejournal.com/144696.html … … 286 293 int forty_two = identity( 42 ); $\C{// T is bound to int, forty\_two == 42}$ 287 294 \end{cfa} 288 Th e @identity@ function abovecan be applied to any complete \newterm{object type} (or @otype@).295 This @identity@ function can be applied to any complete \newterm{object type} (or @otype@). 289 296 The type variable @T@ is transformed into a set of additional implicit parameters encoding sufficient information about @T@ to create and return a variable of that type. 290 297 The \CFA implementation passes the size and alignment of the type represented by an @otype@ parameter, as well as an assignment operator, constructor, copy constructor and destructor. 291 298 If this extra information is not needed, \eg for a pointer, the type parameter can be declared as a \newterm{data type} (or @dtype@). 292 299 293 In \CFA, the polymorphi sm runtime-cost is spread over each polymorphic call, due to passing more argumentsto polymorphic functions;300 In \CFA, the polymorphic runtime-cost is spread over each polymorphic call, because more arguments are passed to polymorphic functions; 294 301 the experiments in Section~\ref{sec:eval} show this overhead is similar to \CC virtual-function calls. 295 302 A design advantage is that, unlike \CC template-functions, \CFA polymorphic-functions are compatible with C \emph{separate compilation}, preventing compilation and code bloat. … … 303 310 which works for any type @T@ with a matching addition operator. 304 311 The polymorphism is achieved by creating a wrapper function for calling @+@ with @T@ bound to @double@, then passing this function to the first call of @twice@. 305 There is now the option of using the same @twice@ and converting the result to @int@ on assignment, or creating another @twice@ with type parameter @T@ bound to @int@ because \CFA uses the return type~\cite{Cormack81,Baker82,Ada} ,in its type analysis.312 There is now the option of using the same @twice@ and converting the result to @int@ on assignment, or creating another @twice@ with type parameter @T@ bound to @int@ because \CFA uses the return type~\cite{Cormack81,Baker82,Ada} in its type analysis. 306 313 The first approach has a late conversion from @double@ to @int@ on the final assignment, while the second has an eager conversion to @int@. 307 314 \CFA minimizes the number of conversions and their potential to lose information, so it selects the first approach, which corresponds with C-programmer intuition. … … 312 319 \begin{cfa} 313 320 void * bsearch( const void * key, const void * base, size_t nmemb, size_t size, 314 int (* compar)( const void *, const void * )); 315 316 int comp( const void * t1, const void * t2 ) { return *(double *)t1 < *(double *)t2 ? -1 : 317 *(double *)t2 < *(double *)t1 ? 1 : 0; } 318 321 int (* compar)( const void *, const void * )); 322 int comp( const void * t1, const void * t2 ) { 323 return *(double *)t1 < *(double *)t2 ? -1 : *(double *)t2 < *(double *)t1 ? 1 : 0; 324 } 319 325 double key = 5.0, vals[10] = { /* 10 sorted float values */ }; 320 326 double * val = (double *)bsearch( &key, vals, 10, sizeof(vals[0]), comp ); $\C{// search sorted array}$ … … 324 330 forall( otype T | { int ?<?( T, T ); } ) T * bsearch( T key, const T * arr, size_t size ) { 325 331 int comp( const void * t1, const void * t2 ) { /* as above with double changed to T */ } 326 return (T *)bsearch( &key, arr, size, sizeof(T), comp ); }327 332 return (T *)bsearch( &key, arr, size, sizeof(T), comp ); 333 } 328 334 forall( otype T | { int ?<?( T, T ); } ) unsigned int bsearch( T key, const T * arr, size_t size ) { 329 335 T * result = bsearch( key, arr, size ); $\C{// call first version}$ 330 return result ? result - arr : size; }$\C{// pointer subtraction includes sizeof(T)}$331 336 return result ? result - arr : size; $\C{// pointer subtraction includes sizeof(T)}$ 337 } 332 338 double * val = bsearch( 5.0, vals, 10 ); $\C{// selection based on return type}$ 333 339 int posn = bsearch( 5.0, vals, 10 ); … … 336 342 Providing a hidden @comp@ function in \CC is awkward as lambdas do not use C calling-conventions and template declarations cannot appear at block scope. 337 343 As well, an alternate kind of return is made available: position versus pointer to found element. 338 \CC's type-system cannot disambiguate between the two versions of @bsearch@ because it does not use the return type in overload resolution, nor can \CC separately compile a template d@bsearch@.344 \CC's type-system cannot disambiguate between the two versions of @bsearch@ because it does not use the return type in overload resolution, nor can \CC separately compile a template @bsearch@. 339 345 340 346 \CFA has replacement libraries condensing hundreds of existing C functions into tens of \CFA overloaded functions, all without rewriting the actual computations (see Section~\ref{sec:libraries}). … … 382 388 \begin{cfa} 383 389 trait otype( dtype T | sized(T) ) { // sized is a pseudo-trait for types with known size and alignment 384 void ?{}( T *); $\C{// default constructor}$385 void ?{}( T *, T ); $\C{// copy constructor}$386 void ?=?( T *, T ); $\C{// assignment operator}$387 void ^?{}( T *); }; $\C{// destructor}$390 void ?{}( T & ); $\C{// default constructor}$ 391 void ?{}( T &, T ); $\C{// copy constructor}$ 392 void ?=?( T &, T ); $\C{// assignment operator}$ 393 void ^?{}( T & ); }; $\C{// destructor}$ 388 394 \end{cfa} 389 395 Given the information provided for an @otype@, variables of polymorphic type can be treated as if they were a complete type: stack-allocatable, default or copy-initialized, assigned, and deleted. … … 429 435 One approach is to write bespoke data-structures for each context in which they are needed. 430 436 While this approach is flexible and supports integration with the C type-checker and tooling, it is also tedious and error-prone, especially for more complex data structures. 431 A second approach is to use @void *@--based polymorphism, \eg the C standard-library functions @bsearch@ and @qsort@, which allow sreuse of code with common functionality.437 A second approach is to use @void *@--based polymorphism, \eg the C standard-library functions @bsearch@ and @qsort@, which allow reuse of code with common functionality. 432 438 However, basing all polymorphism on @void *@ eliminates the type-checker's ability to ensure that argument types are properly matched, often requiring a number of extra function parameters, pointer indirection, and dynamic allocation that is not otherwise needed. 433 439 A third approach to generic code is to use preprocessor macros, which does allow the generated code to be both generic and type-checked, but errors may be difficult to interpret. 434 Furthermore, writing and using preprocessor macros can beunnatural and inflexible.440 Furthermore, writing and using preprocessor macros is unnatural and inflexible. 435 441 436 442 \CC, Java, and other languages use \newterm{generic types} to produce type-safe abstract data-types. … … 444 450 S second; 445 451 }; 446 forall( otype T ) T value( pair( const char *, T ) p ) { return p.second; } 447 forall( dtype F, otype T ) T value( pair( F *, T * ) p ) { return *p.second; } 448 449 pair( const char *, int ) p = { "magic", 42 }; 452 forall( otype T ) T value( pair( const char *, T ) p ) { return p.second; } $\C{// dynamic}$ 453 forall( dtype F, otype T ) T value( pair( F *, T * ) p ) { return *p.second; } $\C{// concrete}$ 454 455 pair( const char *, int ) p = { "magic", 42 }; $\C{// dynamic}$ 450 456 int i = value( p ); 451 pair( void *, int * ) q = { 0, &p.second }; 457 pair( void *, int * ) q = { 0, &p.second }; $\C{// concrete}$ 452 458 i = value( q ); 453 459 double d = 1.0; 454 pair( double *, double * ) r = { &d, &d }; 460 pair( double *, double * ) r = { &d, &d }; $\C{// concrete}$ 455 461 d = value( r ); 456 462 \end{cfa} … … 459 465 Concrete types have a fixed memory layout regardless of type parameters, while dynamic types vary in memory layout depending on their type parameters. 460 466 A type may have polymorphic parameters but still be concrete, called \newterm{dtype-static}. 461 Polymorphic pointers are an example of dtype-static types, \eg @forall(dtype T) T *@ is a polymorphic type, but for any @T@, @T *@ is a fixed-sized pointer, and therefore, can be represented by a @void *@ in code generation.467 Polymorphic pointers are an example of dtype-static, \eg @forall(dtype T) T *@ is a polymorphic type, but for any @T@, @T *@ is a fixed-sized pointer, and therefore, can be represented by a @void *@ in code generation. 462 468 463 469 \CFA generic types also allow checked argument-constraints. … … 475 481 For example, the concrete instantiation for @pair( const char *, int )@ is: 476 482 \begin{cfa} 477 struct _pair_conc 1{483 struct _pair_conc0 { 478 484 const char * first; 479 485 int second; … … 482 488 483 489 A concrete generic-type with dtype-static parameters is also expanded to a structure type, but this type is used for all matching instantiations. 484 In the above example, the @pair( F *, T * )@ parameter to @value _p@ is such a type; its expansion is below and it is used as the type of the variables @q@ and @r@ as well, with casts for member access where appropriate:485 \begin{cfa} 486 struct _pair_conc 0{490 In the above example, the @pair( F *, T * )@ parameter to @value@ is such a type; its expansion is below and it is used as the type of the variables @q@ and @r@ as well, with casts for member access where appropriate: 491 \begin{cfa} 492 struct _pair_conc1 { 487 493 void * first; 488 494 void * second; … … 496 502 As mentioned in Section~\ref{sec:poly-fns}, @otype@ function parameters (in fact all @sized@ polymorphic parameters) come with implicit size and alignment parameters provided by the caller. 497 503 Dynamic generic-types also have an \newterm{offset array} containing structure-member offsets. 498 A dynamic generic- unionneeds no such offset array, as all members are at offset 0, but size and alignment are still necessary.504 A dynamic generic-@union@ needs no such offset array, as all members are at offset 0, but size and alignment are still necessary. 499 505 Access to members of a dynamic structure is provided at runtime via base-displacement addressing with the structure pointer and the member offset (similar to the @offsetof@ macro), moving a compile-time offset calculation to runtime. 500 506 … … 503 509 if the generic type is concrete at the call site, the elements of this offset array can even be statically generated using the C @offsetof@ macro. 504 510 As an example, @p.second@ in the @value@ function above is implemented as @*(p + _offsetof_pair[1])@, where @p@ is a @void *@, and @_offsetof_pair@ is the offset array passed into @value@ for @pair( const char *, T )@. 505 The offset array @_offsetof_pair@ is generated at the call site as @size_t _offsetof_pair[] = { offsetof(_pair_conc 1, first), offsetof(_pair_conc1, second) }@.511 The offset array @_offsetof_pair@ is generated at the call site as @size_t _offsetof_pair[] = { offsetof(_pair_conc0, first), offsetof(_pair_conc0, second) }@. 506 512 507 513 In some cases the offset arrays cannot be statically generated. … … 586 592 \subsection{Tuple Expressions} 587 593 588 The addition of multiple-return-value functions (MRVF) are uselesswithout a syntax for accepting multiple values at the call-site.594 The addition of multiple-return-value functions (MRVF) are \emph{useless} without a syntax for accepting multiple values at the call-site. 589 595 The simplest mechanism for capturing the return values is variable assignment, allowing the values to be retrieved directly. 590 596 As such, \CFA allows assigning multiple values from a function into multiple variables, using a square-bracketed list of lvalue expressions (as above), called a \newterm{tuple}. … … 822 828 \end{cfa} 823 829 so the thunk provides flattening and structuring conversions to inferred functions, improving the compatibility of tuples and polymorphism. 824 These thunks take advantage of gcc C nested-functions to produce closures that have the usual function-pointer signature .830 These thunks take advantage of gcc C nested-functions to produce closures that have the usual function-pointer signature WHAT DOES THIS MEAN???. 825 831 826 832 … … 878 884 print(arg); print(rest); 879 885 } 880 void print( c har * x ) { printf( "%s", x ); }886 void print( const char * x ) { printf( "%s", x ); } 881 887 void print( int x ) { printf( "%d", x ); } 882 888 void print( S s ) { print( "{ ", s.x, ",", s.y, " }" ); } … … 887 893 The polymorphic @print@ allows printing any list of types, where as each individual type has a @print@ function. 888 894 The individual print functions can be used to build up more complicated @print@ functions, such as @S@, which cannot be done with @printf@ in C. 895 This mechanism is used to seamlessly print tuples in the \CFA I/O library (see Section~\ref{s:IOLibrary}). 889 896 890 897 Finally, it is possible to use @ttype@ polymorphism to provide arbitrary argument forwarding functions. … … 1078 1085 While the ability to fall through \emph{is} a useful form of control flow, it does not match well with programmer intuition, resulting in many errors from missing @break@ statements. 1079 1086 For backwards compatibility, \CFA provides a \emph{new} control structure, @choose@, which mimics @switch@, but reverses the meaning of fall through (see Figure~\ref{f:ChooseSwitchStatements}). 1087 1080 1088 Collectively, these enhancements reduce programmer burden and increase readability and safety. 1081 1089 … … 1237 1245 \end{figure} 1238 1246 1239 Both labelled @continue@ and @break@ are a @goto@ restricted in the following ways:1247 With respect to safety, both labelled @continue@ and @break@ are a @goto@ restricted in the following ways: 1240 1248 \begin{itemize} 1241 1249 \item … … 1250 1258 With @goto@, the label is at the end of the control structure, which fails to convey this important clue early enough to the reader. 1251 1259 Finally, using an explicit target for the transfer instead of an implicit target allows new constructs to be added or removed without affecting existing constructs. 1252 The implicit targets of the current @continue@ and @break@, \ie the closest enclosing loop or @switch@, change as certain constructs are added or removed.1260 Otherwise, the implicit targets of the current @continue@ and @break@, \ie the closest enclosing loop or @switch@, change as certain constructs are added or removed. 1253 1261 1254 1262 1255 1263 \subsection{Exception Handling} 1256 1264 1257 The following framework for \CFA exception handling is in place, excluding a run-time typeinformation and dynamic casts.1258 \CFA provides two forms of exception handling: \newterm{fix-up} and \newterm{recovery} (see Figure~\ref{f:CFAExceptionHandling}) .1265 The following framework for \CFA exception handling is in place, excluding some run-time type-information and dynamic casts. 1266 \CFA provides two forms of exception handling: \newterm{fix-up} and \newterm{recovery} (see Figure~\ref{f:CFAExceptionHandling})~\cite{Buhr92b,Buhr00a}. 1259 1267 Both mechanisms provide dynamic call to a handler using dynamic name-lookup, where fix-up has dynamic return and recovery has static return from the handler. 1260 1268 \CFA restricts exception types to those defined by aggregate type @exception@. … … 1333 1341 resume( $\emph{alternate-stack}$ ) 1334 1342 \end{cfa} 1335 These overloads of @resume@ raise the specified exception or the currently propagating exception (reresume) at another coroutine or task~\cite{Delisle18}.1343 These overloads of @resume@ raise the specified exception or the currently propagating exception (reresume) at another \CFA coroutine or task~\cite{Delisle18}.\footnote{\CFA coroutine and concurrency features are discussed in a separately submitted paper.} 1336 1344 Nonlocal raise is restricted to resumption to provide the exception handler the greatest flexibility because processing the exception does not unwind its stack, allowing it to continue after the handle returns. 1337 1345 … … 1358 1366 Specifying no exception type is shorthand for specifying all exception types. 1359 1367 Both @enable@ and @disable@ blocks can be nested, turning propagation on/off on entry, and on exit, the specified exception types are restored to their prior state. 1368 Coroutines and tasks start with non-local exceptions disabled, allowing handlers to be put in place, before non-local exceptions are explicitly enabled. 1369 \begin{cfa} 1370 void main( mytask & c ) { 1371 try { 1372 enable { $\C{// now allow non-local exception delivery}$ 1373 // task body 1374 } 1375 // appropriate catchResume/catch 1376 } 1377 } 1378 \end{cfa} 1360 1379 1361 1380 Finally, \CFA provides a Java like @finally@ clause after the catch clauses: … … 1461 1480 Qualification or a cast is used to disambiguate. 1462 1481 1463 There is an interesting problem between parameters and the function @with@, \eg:1482 There is an interesting problem between parameters and the function-body @with@, \eg: 1464 1483 \begin{cfa} 1465 1484 void ?{}( S & s, int i ) with ( s ) { $\C{// constructor}$ … … 1467 1486 } 1468 1487 \end{cfa} 1469 Here, the assignment @s.i = i@ means @s.i = s.i@, which is meaningless, and there is no mechanism to qualify the parameter @i@, making the assignment impossible using the function @with@.1488 Here, the assignment @s.i = i@ means @s.i = s.i@, which is meaningless, and there is no mechanism to qualify the parameter @i@, making the assignment impossible using the function-body @with@. 1470 1489 To solve this problem, parameters are treated like an initialized aggregate: 1471 1490 \begin{cfa} … … 1475 1494 } params; 1476 1495 \end{cfa} 1477 and implicitly opened \emph{after} a function open, to give them higher priority:1478 \begin{cfa} 1479 void ?{}( S & s, int i) with ( s ) `with( $\emph{\color{red}params}$ )` {1480 s.i = i; j = 3; m = 5.5;1496 and implicitly opened \emph{after} a function-body open, to give them higher priority: 1497 \begin{cfa} 1498 void ?{}( S & s, int `i` ) with ( s ) `with( $\emph{\color{red}params}$ )` { 1499 s.i = `i`; j = 3; m = 5.5; 1481 1500 } 1482 1501 \end{cfa} … … 1539 1558 While attempting to make the two contexts consistent is a laudable goal, it has not worked out in practice. 1540 1559 1541 \CFA provides its own type, variable and function declarations, using a different syntax .1560 \CFA provides its own type, variable and function declarations, using a different syntax~\cite[pp.~856--859]{Buhr94a}. 1542 1561 The new declarations place qualifiers to the left of the base type, while C declarations place qualifiers to the right. 1543 1562 The qualifiers have the same meaning but are ordered left to right to specify a variable's type. … … 1951 1970 } 1952 1971 \end{cfa} 1953 (Note, the example is purposely kept simple byusing shallow-copy semantics.)1972 (Note, the example is purposely simplified using shallow-copy semantics.) 1954 1973 An initialization constructor-call has the same syntax as a C initializer, except the initialization values are passed as arguments to a matching constructor (number and type of paremeters). 1955 1974 \begin{cfa} … … 2004 2023 C already includes limited polymorphism for literals -- @0@ can be either an integer or a pointer literal, depending on context, while the syntactic forms of literals of the various integer and float types are very similar, differing from each other only in suffix. 2005 2024 In keeping with the general \CFA approach of adding features while respecting the ``C-style'' of doing things, C's polymorphic constants and typed literal syntax are extended to interoperate with user-defined types, while maintaining a backwards-compatible semantics. 2006 A trivial example is allowing the underscore, as in Ada, to separate prefixes, digits, and suffixes in all \CFA constants, \eg @0x`_`1.ffff`_`ffff`_`p`_`128`_`l@. 2025 2026 A simple example is allowing the underscore, as in Ada, to separate prefixes, digits, and suffixes in all \CFA constants, \eg @0x`_`1.ffff`_`ffff`_`p`_`128`_`l@, where the underscore is also the standard separator in C identifiers. 2027 \CC uses a single quote as a separator but it is restricted among digits, precluding its use in the literal prefix or suffix, \eg @0x1.ffff@@`'@@ffffp128l@, and causes problems with most IDEs, which must be extended to deal with this alternate use of the single quote. 2007 2028 2008 2029 … … 2014 2035 \begin{tabular}{@{}l@{\hspace{\parindentlnth}}l@{\hspace{\parindentlnth}}l@{}} 2015 2036 \begin{cfa} 2016 20 `_hh` // signed char2017 21 `_hhu` // unsigned char2018 22 `_h` // signed short int2019 23 `_uh` // unsigned short int2020 24 `z`// size_t2021 \end{cfa} 2022 & 2023 \begin{cfa} 2024 20 `_L8` // int8_t2025 21 `_ul8` // uint8_t2026 22 `_l16` // int16_t2027 23 `_ul16` // uint16_t2028 24 `_l32` // int32_t2029 \end{cfa} 2030 & 2031 \begin{cfa} 2032 25 `_ul32` // uint32_t2033 26 `_l64` // int64_t2034 27 `_l64u` // uint64_t2035 26 `_L128` // int1282036 27 `_L128u` // unsigned int1282037 20_`hh` // signed char 2038 21_`hhu` // unsigned char 2039 22_`h` // signed short int 2040 23_`uh` // unsigned short int 2041 24_`z` // size_t 2042 \end{cfa} 2043 & 2044 \begin{cfa} 2045 20_`L8` // int8_t 2046 21_`ul8` // uint8_t 2047 22_`l16` // int16_t 2048 23_`ul16` // uint16_t 2049 24_`l32` // int32_t 2050 \end{cfa} 2051 & 2052 \begin{cfa} 2053 25_`ul32` // uint32_t 2054 26_`l64` // int64_t 2055 27_`l64u` // uint64_t 2056 26_`L128` // int128 2057 27_`L128u` // unsigned int128 2037 2058 \end{cfa} 2038 2059 \end{tabular} … … 2073 2094 After which, user literals must match (no conversions); 2074 2095 hence, it is necessary to overload the unit with all appropriate types. 2075 Finally, the use of the single quote as a separator is restricted to digits, precluding its use in the literal prefix or suffix, and causes problems with most IDEs, which must be extended to deal with this alternate use of the single quote.2076 2096 2077 2097 \begin{figure} … … 2125 2145 w = 155|_lb|; 2126 2146 w = 0b1111|_lb|; // error, binary unsupported 2127 w = 0${\color{red} '}$233|_lb|; // quote separator2147 w = 0${\color{red}\LstBasicStyle{'}}$233|_lb|; // quote separator 2128 2148 w = 0x9b|_kg|; 2129 2149 w = 5.5d|_st| + 8|_kg| + 25.01|_lb| + heavy; … … 2287 2307 \begin{description}[topsep=3pt,itemsep=2pt,parsep=0pt] 2288 2308 \item[fill] 2289 a fter allocation the storage is filledwith a specified character.2309 an allocation with a specified character. 2290 2310 \item[resize] 2291 an existing allocation is decreased or increased insize.2311 an existing allocation to decreased or increased its size. 2292 2312 In either case, new storage may or may not be allocated and, if there is a new allocation, as much data from the existing allocation is copied. 2293 2313 For an increase in storage size, new storage after the copied data may be filled. 2294 2314 \item[alignment] 2295 an allocation startson a specified memory boundary, \eg, an address multiple of 64 or 128 for cache-line purposes.2315 an allocation on a specified memory boundary, \eg, an address multiple of 64 or 128 for cache-line purposes. 2296 2316 \item[array] 2297 the allocation size is scaled to the specified number of arrayelements.2317 allocation of the specified number of elements. 2298 2318 An array may be filled, resized, or aligned. 2299 2319 \end{description} 2300 2320 Table~\ref{t:StorageManagementOperations} shows the capabilities provided by C/\Celeven allocation-functions and how all the capabilities can be combined into two \CFA functions. 2301 2321 \CFA storage-management functions extend the C equivalents by overloading, providing shallow type-safety, and removing the need to specify the base allocation-size. 2302 Figure~\ref{f:StorageAllocation} contrasts \CFA and C storage-allocation operationperforming the same operations with the same type safety.2322 Figure~\ref{f:StorageAllocation} contrasts \CFA and C storage-allocation performing the same operations with the same type safety. 2303 2323 2304 2324 \begin{table} … … 2443 2463 \end{cfa} 2444 2464 \\ 2445 \textbf{output:}2446 2465 & 2447 2466 \begin{cfa}[showspaces=true,aboveskip=0pt] … … 2677 2696 \subsection{Control Structures / Declarations / Literals} 2678 2697 2698 Java has default fall through like C/\CC. 2699 Pascal/Ada/Go/Rust do not have default fall through. 2700 \Csharp does not have fall through but still requires a break. 2701 Python uses dictionary mapping. \\ 2702 \CFA choose is like Rust match. 2703 2704 Java has labelled break/continue. \\ 2705 Languages with and without exception handling. 2706 2707 Alternative C declarations. \\ 2708 Different references \\ 2709 Constructors/destructors 2710 2711 0/1 Literals \\ 2712 user defined: D, Objective-C 2679 2713 2680 2714 \section{Conclusion and Future Work} … … 2683 2717 While other programming languages purport to be a better C, they are in fact new and interesting languages in their own right, but not C extensions. 2684 2718 The purpose of this paper is to introduce \CFA, and showcase language features that illustrate the \CFA type-system and approaches taken to achieve the goal of evolutionary C extension. 2685 The contributions are a powerful type-system using parametric polymorphism and overloading, generic types, and tuples, which all have complex interactions.2719 The contributions are a powerful type-system using parametric polymorphism and overloading, generic types, tuples, advanced control structures, and extended declarations, which all have complex interactions. 2686 2720 The work is a challenging design, engineering, and implementation exercise. 2687 2721 On the surface, the project may appear as a rehash of similar mechanisms in \CC. … … 2690 2724 Finally, we demonstrate that \CFA performance for some idiomatic cases is better than C and close to \CC, showing the design is practically applicable. 2691 2725 2692 There is ongoing work on a wide range of \CFA feature extensions, including arrays with size, exceptions, concurrent primitives, modules, and user-defined conversions.2726 There is ongoing work on a wide range of \CFA feature extensions, including arrays with size, user-defined conversions, concurrent primitives, and modules. 2693 2727 (While all examples in the paper compile and run, a public beta-release of \CFA will take another 8--12 months to finalize these additional extensions.) 2694 2728 In addition, there are interesting future directions for the polymorphism design. … … 2703 2737 \section{Acknowledgments} 2704 2738 2705 The authors would like to recognize the design assistance of Glen Ditchfield, Richard Bilson, and Thierry Delisleon the features described in this paper, and thank Magnus Madsen for feedback in the writing.2706 This work is supported through a corporate partnership with Huawei Ltd.\ (\url{http://www.huawei.com}), and Aaron Moss and Peter Buhr are funded by the Natural Sciences and Engineering Research Council of Canada.2739 The authors would like to recognize the design assistance of Glen Ditchfield, Richard Bilson, Thierry Delisle, and Andrew Beach on the features described in this paper, and thank Magnus Madsen for feedback in the writing. 2740 This work is supported through a corporate partnership with Huawei Ltd.\ (\url{http://www.huawei.com}), and Aaron Moss and Peter Buhr are partially funded by the Natural Sciences and Engineering Research Council of Canada. 2707 2741 2708 2742 % the first author's \grantsponsor{NSERC-PGS}{NSERC PGS D}{http://www.nserc-crsng.gc.ca/Students-Etudiants/PG-CS/BellandPostgrad-BelletSuperieures_eng.asp} scholarship.
Note: See TracChangeset
for help on using the changeset viewer.