Changeset 8ef0bf7 for doc/theses


Ignore:
Timestamp:
Mar 26, 2025, 9:41:52 AM (2 weeks ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
master
Children:
379b6ea
Parents:
d73e667
Message:

update Table 1.1

File:
1 edited

Legend:

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

    rd73e667 r8ef0bf7  
    888888\section{Language Comparison}
    889889
    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 
    906890\begin{table}
    907 \caption{Overload Discriminating Features in Programming Languages}
     891\caption{Overload Features in Programming Languages}
    908892\label{t:OverloadingFeatures}
    909893\centering
     
    915899general\footnote{overloadable entities: V $\Rightarrow$ variable, O $\Rightarrow$ operator, F $\Rightarrow$ function, M $\Rightarrow$ member}
    916900                                                & 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}
     901general constraints\footnote{parameter \# $\Rightarrow$ number, T $\Rightarrow$ type, N $\Rightarrow$ name; R $\Rightarrow$ return type}
    918902                                                & \#/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 \\
     903type parameters                 & no            & yes   & yes           & yes   & yes           & yes           & yes   & yes \\
    920904type 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 \\
     906Safe/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
    929909\end{tabular}
    930910\end{minipage}
     
    932912% https://dl.acm.org/doi/10.1145/75277.75283
    933913\end{table}
     914
     915Because \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.
     916The 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}
     922int foo;
     923double foo;
     924
     925
     926\end{cfa}
     927&
     928\begin{cfa}
     929int ?+?( int );
     930double ?+?( double );
     931
     932
     933\end{cfa}
     934&
     935\begin{cfa}
     936int foo( int );
     937double foo( int, int );
     938
     939
     940\end{cfa}
     941&
     942\begin{c++}
     943class C {
     944        int foo( int );
     945        double foo( int, int );
     946};
     947\end{c++}
     948\end{tabular}
     949\end{cquote}
     950The 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]
     955func foo( _ x : Int )
     956func foo( _ x : Int, _ y : Int )
     957foo( 3 )
     958foo( 3, 3 )
     959\end{lstlisting}
     960&
     961\begin{lstlisting}[language=swift]
     962func foo( _ x : Int )
     963func foo( _ x : Double )
     964foo( 3 )
     965foo( 3.5 )
     966\end{lstlisting}
     967&
     968\begin{lstlisting}[language=swift]
     969func foo( x : Int )
     970func foo( y : Int )
     971foo( x : 3 )
     972foo( y : 3 );
     973\end{lstlisting}
     974&
     975\begin{lstlisting}[language=swift]
     976func foo() -> Int
     977func foo() -> String
     978var i : Int = foo()
     979var s : String = foo();
     980\end{lstlisting}
     981\end{tabular}
     982\end{cquote}
     983The third row classifies if generic functions can be overloaded based on the number and differing type variables.
     984\begin{cfa}
     985forall( T ) T foo( T t );
     986forall( T ) T foo( T t, T s );
     987forall( T, U ) T foo( T t, U s );
     988\end{cfa}
     989The fourth row classifies the mechanism used to specialize the type variables to make them practical.
     990\begin{cfa}
     991forall( T | T ?+?( T, T ) ) T foo( T t );
     992\end{cfa}
     993The fifth row classifies if conversions are attempted beyond exact match.
     994\begin{cfa}
     995int foo( double ); // 1
     996double foo( int ); // 2
     997int i = foo( 3 ); // 1 : 3 => 3.0
     998double d = foo( 3.5 ); // 1 : int result => double
     999\end{cfa}
    9341000
    9351001
Note: See TracChangeset for help on using the changeset viewer.