Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • doc/generic_types/generic_types.tex

    r32bcef7 re6dceef  
    11% take off review (for line numbers) and anonymous (for anonymization) on submission
    2 % \documentclass[format=acmlarge, anonymous, review]{acmart}
    3 \documentclass[format=acmlarge,review]{acmart}
     2\documentclass[format=acmlarge,anonymous,review]{acmart}
     3% \documentclass[format=acmlarge,review]{acmart}
    44
    55\usepackage{xspace,calc,comment}
     
    226226\end{lstlisting}
    227227Within the block, the nested version of @<@ performs @>@ and this local version overrides the built-in @<@ so it is passed to @qsort@.
    228 Hence, programmers can easily form local environments, adding and modifying appropriate functions, to maximize reuse of other existing functions and types.
     228Hence, programmers can easily form a local environments, adding and modifying appropriate functions, to maximize reuse of other existing functions and types.
    229229
    230230Finally, \CFA allows variable overloading:
     
    758758It is also possible to use @ttype@ polymorphism to provide arbitrary argument forwarding functions. For example, it is possible to write @new@ as a library function:
    759759\begin{lstlisting}
    760 struct Pair(otype R, otype S);
     760struct pair(otype R, otype S);
    761761forall(otype R, otype S)
    762 void ?{}(Pair(R, S) *, R, S);  // (1)
     762void ?{}(pair(R, S) *, R, S);  // (1)
    763763
    764764forall(dtype T, ttype Params | sized(T) | { void ?{}(T *, Params); })
     
    767767}
    768768
    769 Pair(int, char) * x = new(42, '!');
     769pair(int, char) * x = new(42, '!');
    770770\end{lstlisting}
    771771The @new@ function provides the combination of type-safe @malloc@ with a constructor call, so that it becomes impossible to forget to construct dynamically allocated objects. This function provides the type-safety of @new@ in \CC, without the need to specify the allocated type again, thanks to return-type inference.
    772772
    773 In the call to @new@, @Pair(double, char)@ is selected to match @T@, and @Params@ is expanded to match @[double, char]@. The constructor (1) may be specialized to  satisfy the assertion for a constructor with an interface compatible with @void ?{}(Pair(int, char) *, int, char)@.
    774 
    775 \TODO{Check if we actually can use ttype parameters on generic types (if they set the complete flag, it should work, or nearly so).}
     773In the call to @new@, @pair(double, char)@ is selected to match @T@, and @Params@ is expanded to match @[double, char]@. The constructor (1) may be specialized to  satisfy the assertion for a constructor with an interface compatible with @void ?{}(pair(int, char) *, int, char)@.
    776774
    777775\subsection{Implementation}
Note: See TracChangeset for help on using the changeset viewer.