Changeset 6740533e
- Timestamp:
- Jul 31, 2024, 7:41:21 PM (3 months ago)
- Branches:
- master
- Children:
- 3a7cd15
- Parents:
- 21f4dff
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/theses/jiada_liang_MMath/trait.tex
r21f4dff r6740533e 97 97 \end{cfa} 98 98 99 \subsection{Bounded and Serial} 99 \section{Discussion: Static Type Information} 100 @CfaEnum@ and @TypedEnum@ are approximations to \CFA Enumerations and Typed Enumerations: they are not 101 assertions on a type being an enumerated type, 102 but rather types being shared an interfaces with \CFA enumerations. 103 \CC's @type_traits@ is fundamentally different than \CFA's traits: \CC's @type_traits@ are descriptions 104 of compile time type information 105 \footnote{Concepts can check if a \CC class implement a certain method, 106 but it is to probe a static type information of a class having a such member.} 107 , while \CFA's trait describe how a type can be used, 108 which is a closer paradigm to a trait system in languages such as Scala and Rust. 109 However, Scala and Rust's traits are nominative: 110 a type explicitly declare a named traits to be of its type; while in \CFA, 111 type implements all functions declares in a trait to implicitly be of the trait type. 112 113 If to support static type information, \CFA needs new piece of syntax to distinguish static type 114 query from function calls, for example: 115 \begin{cfa} 116 forall(T | { T::is_enum; }); 117 \end{cfa} 118 When to call a polymorphic function @foo(T)@ with assertions set @S@ and function call argument @a@, \CFA 119 determines if there is an overloaded name @a@ that has non-zero conversion cost to all assertions in @S@. 120 As a consequence, @is_enum@ can be a \CFA directive that immediately trim down the search space of @a@ to 121 be some enumerated types. In fact, because \CFA stores symbols maps to enumeration in a standalone data structure. 122 Limiting search space to enumeration improve on \CFA resolution speed. 123 124 While assertion on static type information seems improvement on expressivity, it is a challenge to 125 extend its capability without a fully functional pre-processsor that evaluate constant expression as \CC 126 compilers does. The described @is_enum@ manipulate compiler behaviour, which cannot be easily extended to 127 other usage cases. Therefore, \CFA currently does not support @is_enum@ and utalizes traits as a workaround. 128 129 130 \section{Bounded and Serial} 100 131 A bounded type defines a lower bound and a upper bound. 101 132 \begin{cfa}
Note: See TracChangeset
for help on using the changeset viewer.