Changes in / [379b6ea:446dde5]


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • doc/theses/fangren_yu_MMath/intro.tex

    r379b6ea r446dde5  
    888888\section{Language Comparison}
    889889
     890Because \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.
     891The first row classifies whether there is general overloading, and what enities may be overloaded.
     892\begin{cfa}
     893int foo( int );                                 int foo;
     894double foo( int, int );                 double foo;
     895\end{cfa}
     896The second row classifies the specialzation mechanisms used distinished among the general overloads.
     897The third row classifies if generic functions can be overloaded based on the number and differing type variables.
     898\begin{cfa}
     899forall( T ) T foo( T t );
     900forall( T ) T foo( T t, T s );
     901forall( T, U ) T foo( T t, U s );
     902\end{cfa}
     903The fourth row classifies the mechnaism used to specialize  provide  if generic functions can be overloaded based on the number and differing type variables.
     904The fifth row classifies if conversions are attempted beyond exact match.
     905
    890906\begin{table}
    891 \caption{Overload Features in Programming Languages}
     907\caption{Overload Discriminating Features in Programming Languages}
    892908\label{t:OverloadingFeatures}
    893909\centering
     
    899915general\footnote{overloadable entities: V $\Rightarrow$ variable, O $\Rightarrow$ operator, F $\Rightarrow$ function, M $\Rightarrow$ member}
    900916                                                & O\footnote{except assignment}/F       & O/F/M & V/O/F & M\footnote{not universal}     & O/M   & O/F/M & no    & no    \\
    901 general constraints\footnote{parameter \# $\Rightarrow$ number, T $\Rightarrow$ type, N $\Rightarrow$ name; R $\Rightarrow$ return type}
     917general constraints\footnote{\# $\Rightarrow$ number, T $\Rightarrow$ type, N $\Rightarrow$ name, R $\Rightarrow$ return type}
    902918                                                & \#/T/R        & \#/T  & \#/T/R        & \#/T  & \#/T/N/R      & \#/T/N/R      & \#/T/N        & T/R \\
    903 type parameters                 & no            & yes   & yes           & yes   & yes           & yes           & yes   & yes \\
     919type parameters                 & no            & yes   & yes           & yes   & yes   & yes   & yes   & yes \\
    904920type constraint\footnote{T $\Rightarrow$ trait/concept, B $\Rightarrow$ type bounds, TC $\Rightarrow$ type class}
    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
     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   \\
     926Safe/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
    909929\end{tabular}
    910930\end{minipage}
     
    912932% https://dl.acm.org/doi/10.1145/75277.75283
    913933\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}
    1000934
    1001935
Note: See TracChangeset for help on using the changeset viewer.