Changeset 206f4cf
- Timestamp:
- May 19, 2025, 3:01:48 PM (4 weeks ago)
- Branches:
- master
- Children:
- 00ad2a0
- Parents:
- 8b3109b
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/theses/fangren_yu_MMath/background.tex
r8b3109b r206f4cf 8 8 Haskell~\cite{Haskell10} combines ML-style polymorphism, polymorphic data types, and type inference with the notion of type classes, collections of overloadable methods. 9 9 The class/type-class association constrain type arguments by indicating the set of functions that become implicit assertion arguments and specify the implementation of these operations. 10 As pointed out \see{\VRef[Figure]{f:ImplicitExplicitTraitInferencing}}, Haskell requires an explicit association between types and constrain s (type-class).10 As pointed out \see{\VRef[Figure]{f:ImplicitExplicitTraitInferencing}}, Haskell requires an explicit association between types and constraints (type-class). 11 11 Otherwise, Haskell does not provide general overloading. 12 12 \CFA differs by allowing general overloading and constraining type arguments with traits. … … 16 16 Selecting among them and understanding how they interact is part of the challenge in \CC program development. 17 17 General overloading is available, subtyping inheritance can be single or multiple, templates are typed macro-expansion over a universal type, which precludes separate compilation. 18 Universal template types are constrained using @concept@s~\cite{C++Concepts}, but only as a guideline, as the template expansion can still discover additional constrain s.18 Universal template types are constrained using @concept@s~\cite{C++Concepts}, but only as a guideline, as the template expansion can still discover additional constraints. 19 19 Template expansion can result in code bloat and poor error messages. 20 20 Type inferencing is available using \lstinline[language=C++]{auto}, precluding using the return type for overload selection. 21 \CFA differs by providing a simplified, uniform facility for polymorphic code, eliminating subtyping polymorphi c, and encompassing overloading among parametric functions and universal (generic) types, all of which are separately compilable.21 \CFA differs by providing a simplified, uniform facility for polymorphic code, eliminating subtyping polymorphism, and encompassing overloading among parametric functions and universal (generic) types, all of which are separately compilable. 22 22 Overload resolution uses the return type and arithmetic conversions to make precise function selections versus generating ambiguities, at the cost of type inferencing. 23 23 Both \CFA call-site inferencing and \CC template expansion search in the local environment to satisfy explicit assertions or to find named functions to complete the template, respectively. … … 40 40 \CFA's path for modernizing works with the existing C type system and runtime, \ie not adding object-oriented types or garbage collection. 41 41 Java~\cite{Java8} has object-oriented subtyping, generic @interface@s that act like traits, which are type checked at compilation and type erased at runtime similar to \CFA's, and general overloading on methods. 42 However, in Java, each object carries its own table of method pointers, whereas \CFA passes trait pointers at call-site maintaining a C-compatible layout.42 However, in Java, each class carries its own table of method pointers, and use of interfaces must be pre-declared with the @implements@ keyword, whereas \CFA passes trait pointers at call-site maintaining a C-compatible layout. 43 43 Java is also garbage-collected. 44 44 … … 48 48 Go's generic types and functions are limited to a small fixed-set provided by the compiler, with no language facility to define more. 49 49 Rust also possesses more powerful abstraction capabilities for writing generic code than Go. 50 While Rust's borrow checker provides strong safety guarantees, it is complex and difficult to learn and imposes a distinctly idiomatic programming style different thanC.51 \CFA, with its modest safety features, has a comparable type-system to Rust's , while maintaining C backwards compatibility, providinga modernization path for existing C code-bases.50 While Rust's borrow checker provides strong safety guarantees, it is complex and difficult to learn, and imposes a distinctly idiomatic programming style different from C. 51 \CFA, with its modest safety features, has a comparable type-system to Rust's that also maintains C backwards compatibility, which provides a modernization path for existing C code-bases. 52 52 53 53 … … 66 66 While \CFA has some structured-tuple capabilities, \VRef{s:TupleImplementation}, my analysis suggests this feature might be removed. 67 67 68 An alternative to a tuple type is of variadic (variable argument) functions or type.68 An alternative to tuple types is variadic (variable number of arguments) functions or types. 69 69 C provides variadic functions through @va_list@ objects, but the programmer is responsible for managing the number of arguments and their types; 70 70 thus, the mechanism is type unsafe. … … 72 72 Tuples are a generalization of @std::pair@ allowing for arbitrary length, fixed-size aggregation of heterogeneous values. 73 73 Operations include @std::get<N>@ to extract values, @std::tie@ to create a tuple of references used for assignment, and lexicographic comparisons. 74 \CC{17} proposes \emph{structured bindings}~\cite{Sutter15} to eliminate pre declaring variables and the use of @std::tie@ for binding the results.74 \CC{17} proposes \emph{structured bindings}~\cite{Sutter15} to eliminate pre-declaring variables and the use of @std::tie@ for binding the results. 75 75 This extension requires the use of @auto@ to infer the types of the new variables; hence, complicated expressions with a nonobvious type must be documented with some other mechanism. 76 76 Furthermore, structured bindings are not a full replacement for @std::tie@, as it always declares new variables. 77 77 Java's variadic functions appear similar to C's but are type safe using homogeneous arrays. 78 \CFA's heterogeneous variadic -functions \see{\VPageref{p:VariadicFunctions}} provide a type-safe version of C variadic, although limited in features, which fits into the overall \CFA type-system design.78 \CFA's heterogeneous variadic functions \see{\VPageref{p:VariadicFunctions}} provide a type-safe version of C variadic, although limited in features, which fits into the overall \CFA type-system design. 79 79 80 80
Note: See TracChangeset
for help on using the changeset viewer.