Ignore:
Timestamp:
Apr 11, 2017, 6:35:59 PM (5 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
aaron-thesis, arm-eh, cleanup-dtors, deferred_resn, demangler, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, resolv-new, with_gc
Children:
3720bf8f
Parents:
f674479 (diff), 4f57930 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of plg2:software/cfa/cfa-cc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • doc/generic_types/generic_types.tex

    rf674479 rda1c772  
    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}
     
    760760It 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:
    761761\begin{lstlisting}
    762 struct Pair(otype R, otype S);
     762struct pair(otype R, otype S);
    763763forall(otype R, otype S)
    764 void ?{}(Pair(R, S) *, R, S);  // (1)
     764void ?{}(pair(R, S) *, R, S);  // (1)
    765765
    766766forall(dtype T, ttype Params | sized(T) | { void ?{}(T *, Params); })
     
    769769}
    770770
    771 Pair(int, char) * x = new(42, '!');
     771pair(int, char) * x = new(42, '!');
    772772\end{lstlisting}
    773773The @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.
    774774
    775 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)@.
    776 
    777 \TODO{Check if we actually can use ttype parameters on generic types (if they set the complete flag, it should work, or nearly so).}
     775In 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)@.
    778776
    779777\subsection{Implementation}
Note: See TracChangeset for help on using the changeset viewer.