Changeset 2514d3d7
- Timestamp:
- Aug 5, 2024, 9:27:42 AM (4 months ago)
- Branches:
- master
- Children:
- 94643698
- Parents:
- 7ab24fef
- git-author:
- Peter A. Buhr <pabuhr@…> (08/05/24 09:26:38)
- git-committer:
- Peter A. Buhr <pabuhr@…> (08/05/24 09:27:42)
- Location:
- doc/theses/jiada_liang_MMath
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/theses/jiada_liang_MMath/background.tex
r7ab24fef r2514d3d7 235 235 236 236 \subsection{Function Overloading} 237 Function overloading is programming languages feature wherein functions may share the same name, but with different function signatures. In both C++ and \CFA, function names can be overloaded 237 Function overloading is programming languages feature wherein functions may share the same name, but with different function signatures. In both C++ and \CFA, function names can be overloaded 238 238 with different entities as long as they are different in terms of the number and type of parameters. 239 239 … … 381 381 \end{cfa} 382 382 The @identity@ function accepts a value from any type as an argument and returns that value. 383 At the call size, the type parameter @T@ is bounded to @int@ from the argument @42@. 384 385 For polymorphic functions to be useful, the @forall@ clause needs \newterm{type assertion}s that restricts the polymorphic types it accepts. 383 At the call size, the type parameter @T@ is bounded to @int@ from the argument @42@. 384 385 For polymorphic functions to be useful, the @forall@ clause needs \newterm{type assertion}s that restricts the polymorphic types it accepts. 386 386 \begin{cfa} 387 387 forall( T @| { void foo( T ); }@ ) void bar( T t ) { @foo( t );@ } … … 394 394 \subsection{Trait} 395 395 A @forall@ clause can asserts on multiple types and with multiple asserting functions. A common practice in \CFA is to group 396 the asserting functions in to a named \newterm{trait}. 396 the asserting functions in to a named \newterm{trait}. 397 397 398 398 \subsection{Trait} 399 399 400 400 A @forall@ clause can assert many restrictions on multiple types. 401 A common practice is to refactor the assertions into a named \newterm{trait}. 401 A common practice is to refactor the assertions into a named \newterm{trait}. 402 402 \begin{cfa} 403 403 forall(T) trait @Bird@ { … … 434 434 otherwise, the program becomes littered with many explicit casts, which is not match programmer expectation. 435 435 C is an aggressive language as it provides conversions among almost all of the basic types, even when the conversion is potentially unsafe or not meaningful, \ie @float@ to @bool@. 436 C defines the resolution pattern as ``usual arithmetic conversion''~\cite[\S~6.3.1.8]{C11}, in which C looks for a \newterm{common type} between operands, and converts one or both operands to the common type. 436 C defines the resolution pattern as ``usual arithmetic conversion''~\cite[\S~6.3.1.8]{C11}, in which C looks for a \newterm{common type} between operands, and converts one or both operands to the common type. 437 437 Loosely defined, a common type is a the smallest type in terms of size of representation that both operands can be converted into without losing their precision, called a \newterm{widening} or \newterm{safe conversion}. 438 438 … … 447 447 @safe@ is sum of the degree of safe (widening) conversions. 448 448 \end{enumerate} 449 Sum of degree is a method to quantify C's integer and floating-point rank. 449 Sum of degree is a method to quantify C's integer and floating-point rank. 450 450 Every pair of widening conversion types is assigned a \newterm{distance}, and distance between the two same type is 0. 451 451 For example, the distance from @char@ to @int@ is 2, distance from @int@ to @long@ is 1, and distance from @int@ to @long long int@ is 2. … … 494 494 495 495 In \CFA, the meaning of a C style cast is determined by its @Cast Cost@. For most cast expression resolution, a cast cost is equal to a conversion cost. 496 Cast cost exists as an independent matrix for conversion that cannot happen implcitly, while being possible with an explicit cast. These conversions are often defined to have 496 Cast cost exists as an independent matrix for conversion that cannot happen implcitly, while being possible with an explicit cast. These conversions are often defined to have 497 497 infinite conversion cost and non-infinite cast cost. -
doc/theses/jiada_liang_MMath/intro.tex
r7ab24fef r2514d3d7 299 299 \begin{enumerate} 300 300 \item 301 overloading: 301 overloading: 302 302 \item 303 303 scoping
Note: See TracChangeset
for help on using the changeset viewer.