- Timestamp:
- Feb 4, 2025, 9:16:19 PM (3 months ago)
- Branches:
- master
- Children:
- 985ff5f
- Parents:
- bbbff10
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified doc/theses/fangren_yu_MMath/intro.tex ¶
rbbbff10 r7846f91 43 43 44 44 Virtually all programming languages overload the arithmetic operators across the basic computational types using the number and type of parameters and returns. 45 Like \CC, \CFA maps operators to named functions and allows these operators to be overloaded with user-defined types. 45 However, in many programming languages, arithmetic operators are not first class, and hence, they cannot be overloaded by programmers. 46 Like \CC, \CFA maps operators to named functions allowing them to be overloaded with user-defined types. 46 47 The syntax for operator names uses the @'?'@ character to denote a parameter, \eg left and right unary operators: @?++@ and @++?@, and binary operators @?+?@ and @?<=?@. 47 48 Here, a user-defined type is extended with an addition operation with the same syntax as a builtin type. … … 171 172 172 173 174 \section{Overload Resolution Strategies} 175 176 For languages with user-defined overloading, 177 Given an overloaded constant, variable, or (generic) function, there must exist strategies for differentiating among them and selecting the most appropriate one in a given context. 178 The criteria commonly used to match operator/function/method names with definitions are: number of parameters, parameter types, parameter order or name, return type, implicit argument type conversions (safe/unsafe), generic, where some features are missing in certain programming languages. 179 \VRef[Table]{t:OverloadingFeatures} shows a subset of popular programming languages with overloading and the discriminating features used to disambiguate among overloadings. 180 Language C, Go and Rust have no overloading beyond basic types and operators. 181 182 \begin{table} 183 \caption{Overload Discriminating Features in Programming Languages} 184 \label{t:OverloadingFeatures} 185 \centering 186 187 188 \begin{minipage}{0.75\textwidth} 189 \begin{tabular}{@{}r|ccccccc@{}} 190 Feat.\,{\textbackslash}\,Lang. & Ada & \CC & \CFA & Java & Scala & Swift & Haskell \\ 191 \hline 192 Oper./Func./Meth. name & O\footnote{except assignment}/F & O/F/M & O/F & M & O/M & O/F/M \\ 193 \# of parameters & yes & yes & yes & yes & yes & yes \\ 194 parameter types & yes & yes & yes & yes & yes & yes \\ 195 parameter Order/Name & O/N & O & O & O & & O/N \\ 196 return type & yes & no & yes & no & & yes \\ 197 Safe/Unsafe arg. conv. & & & S/U & & & no\footnote{literals only, Int -> Double (Safe)} \\ 198 generic & & & yes & & & yes 199 \end{tabular} 200 \end{minipage} 201 \end{table} 202 203 173 204 \section{Type Inferencing} 174 205 \label{s:IntoTypeInferencing}
Note: See TracChangeset
for help on using the changeset viewer.