Changeset 8ef0bf7 for doc/theses
- Timestamp:
- Mar 26, 2025, 9:41:52 AM (2 weeks ago)
- Branches:
- master
- Children:
- 379b6ea
- Parents:
- d73e667
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified doc/theses/fangren_yu_MMath/intro.tex ¶
rd73e667 r8ef0bf7 888 888 \section{Language Comparison} 889 889 890 Because \CFA's type system is focused on overloading and overload resolution, \VRef[Table]{t:OverloadingFeatures} compares \CFA with a representive set of popular programming languages and their take on overloading.891 The first row classifies whether there is general overloading, and what enities may be overloaded.892 \begin{cfa}893 int foo( int ); int foo;894 double foo( int, int ); double foo;895 \end{cfa}896 The second row classifies the specialzation mechanisms used distinished among the general overloads.897 The third row classifies if generic functions can be overloaded based on the number and differing type variables.898 \begin{cfa}899 forall( T ) T foo( T t );900 forall( T ) T foo( T t, T s );901 forall( T, U ) T foo( T t, U s );902 \end{cfa}903 The fourth row classifies the mechnaism used to specialize provide if generic functions can be overloaded based on the number and differing type variables.904 The fifth row classifies if conversions are attempted beyond exact match.905 906 890 \begin{table} 907 \caption{Overload DiscriminatingFeatures in Programming Languages}891 \caption{Overload Features in Programming Languages} 908 892 \label{t:OverloadingFeatures} 909 893 \centering … … 915 899 general\footnote{overloadable entities: V $\Rightarrow$ variable, O $\Rightarrow$ operator, F $\Rightarrow$ function, M $\Rightarrow$ member} 916 900 & O\footnote{except assignment}/F & O/F/M & V/O/F & M\footnote{not universal} & O/M & O/F/M & no & no \\ 917 general constraints\footnote{ \# $\Rightarrow$ number, T $\Rightarrow$ type, N $\Rightarrow$ name,R $\Rightarrow$ return type}901 general constraints\footnote{parameter \# $\Rightarrow$ number, T $\Rightarrow$ type, N $\Rightarrow$ name; R $\Rightarrow$ return type} 918 902 & \#/T/R & \#/T & \#/T/R & \#/T & \#/T/N/R & \#/T/N/R & \#/T/N & T/R \\ 919 type parameters & no & yes & yes & yes & yes & yes& yes & yes \\903 type parameters & no & yes & yes & yes & yes & yes & yes & yes \\ 920 904 type constraint\footnote{T $\Rightarrow$ trait/concept, B $\Rightarrow$ type bounds, TC $\Rightarrow$ type class} 921 & no & T & T & T & B & T & T & TC \\ 922 %parameter number & yes & yes & yes & yes & yes & yes & maybe & no \\ 923 %parameter types & yes & yes & yes & yes & yes & yes & yes & yes \\ 924 %parameter name & no & no & no & no & yes & yes & no & no \\ 925 %return type & yes & no & yes & no & no & yes & no & yes \\ 926 Safe/Unsafe arg. conv. & no & S/U\footnote{no conversions allowed during template parameter deduction} & S/U 927 & S\footnote{unsafe (narrowing) conversion only allowed in assignment or initialization to a primitive (builtin) type} & S 928 & no\footnote{literals only, Int $\rightarrow$ Double (Safe)} & no & no 905 & no & T & T & T & B & T & T & TC \\ 906 Safe/Unsafe arg. conv. & no & S/U\footnote{no conversions allowed during template parameter deduction} & S/U 907 & S\footnote{unsafe (narrowing) conversion only allowed in assignment or initialization to a primitive (builtin) type} & S 908 & no\footnote{literals only, Int $\rightarrow$ Double (Safe)} & no & no 929 909 \end{tabular} 930 910 \end{minipage} … … 932 912 % https://dl.acm.org/doi/10.1145/75277.75283 933 913 \end{table} 914 915 Because \CFA's type system is focused on overloading and overload resolution, \VRef[Table]{t:OverloadingFeatures} compares \CFA with a representative set of popular programming languages and their take on overloading. 916 The first row classifies whether there is general overloading, and what entities may be overloaded. 917 \begin{cquote} 918 \setlength{\tabcolsep}{10pt} 919 \begin{tabular}{@{}llll@{}} 920 \multicolumn{1}{c}{\textbf{variable}} & \multicolumn{1}{c}{\textbf{operator}} & \multicolumn{1}{c}{\textbf{function}} & \multicolumn{1}{c}{\textbf{member}} \\ 921 \begin{cfa} 922 int foo; 923 double foo; 924 925 926 \end{cfa} 927 & 928 \begin{cfa} 929 int ?+?( int ); 930 double ?+?( double ); 931 932 933 \end{cfa} 934 & 935 \begin{cfa} 936 int foo( int ); 937 double foo( int, int ); 938 939 940 \end{cfa} 941 & 942 \begin{c++} 943 class C { 944 int foo( int ); 945 double foo( int, int ); 946 }; 947 \end{c++} 948 \end{tabular} 949 \end{cquote} 950 The second row classifies the specialization mechanisms used to distinguish among the general overload capabilities. 951 \begin{cquote} 952 \begin{tabular}{@{}llll@{}} 953 \multicolumn{1}{c}{\textbf{number}} & \multicolumn{1}{c}{\textbf{type}} & \multicolumn{1}{c}{\textbf{name}} & \multicolumn{1}{c}{\textbf{return}} \\ 954 \begin{lstlisting}[language=swift] 955 func foo( _ x : Int ) 956 func foo( _ x : Int, _ y : Int ) 957 foo( 3 ) 958 foo( 3, 3 ) 959 \end{lstlisting} 960 & 961 \begin{lstlisting}[language=swift] 962 func foo( _ x : Int ) 963 func foo( _ x : Double ) 964 foo( 3 ) 965 foo( 3.5 ) 966 \end{lstlisting} 967 & 968 \begin{lstlisting}[language=swift] 969 func foo( x : Int ) 970 func foo( y : Int ) 971 foo( x : 3 ) 972 foo( y : 3 ); 973 \end{lstlisting} 974 & 975 \begin{lstlisting}[language=swift] 976 func foo() -> Int 977 func foo() -> String 978 var i : Int = foo() 979 var s : String = foo(); 980 \end{lstlisting} 981 \end{tabular} 982 \end{cquote} 983 The third row classifies if generic functions can be overloaded based on the number and differing type variables. 984 \begin{cfa} 985 forall( T ) T foo( T t ); 986 forall( T ) T foo( T t, T s ); 987 forall( T, U ) T foo( T t, U s ); 988 \end{cfa} 989 The fourth row classifies the mechanism used to specialize the type variables to make them practical. 990 \begin{cfa} 991 forall( T | T ?+?( T, T ) ) T foo( T t ); 992 \end{cfa} 993 The fifth row classifies if conversions are attempted beyond exact match. 994 \begin{cfa} 995 int foo( double ); // 1 996 double foo( int ); // 2 997 int i = foo( 3 ); // 1 : 3 => 3.0 998 double d = foo( 3.5 ); // 1 : int result => double 999 \end{cfa} 934 1000 935 1001
Note: See TracChangeset
for help on using the changeset viewer.