Changeset bfd7b30 for doc/theses/andrew_beach_MMath
- Timestamp:
- Aug 12, 2021, 8:07:39 AM (3 years ago)
- Branches:
- ADT, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 93d0ed3
- Parents:
- b42d0ea
- Location:
- doc/theses/andrew_beach_MMath
- Files:
-
- 1 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/theses/andrew_beach_MMath/features.tex
rb42d0ea rbfd7b30 130 130 131 131 \section{Virtuals} 132 \label{s:Virtuals} 132 133 Virtual types and casts are not part of \CFA's EHM nor are they required for 133 134 an EHM. 134 135 However, one of the best ways to support an exception hierarchy 135 136 is via a virtual hierarchy and dispatch system. 136 137 137 Ideally, the virtual system should have been part of \CFA before the work 138 138 on exception handling began, but unfortunately it was not. … … 149 149 number of children. 150 150 Any type that belongs to any of these trees is called a virtual type. 151 151 For example, the following hypothetical syntax creates two virtual-type trees. 152 \begin{flushleft} 153 \lstDeleteShortInline@ 154 \begin{tabular}{@{\hspace{20pt}}l@{\hspace{20pt}}l} 155 \begin{cfa} 156 vtype V0, V1(V0), V2(V0); 157 vtype W0, W1(W0), W2(W1); 158 \end{cfa} 159 & 160 \raisebox{-0.6\totalheight}{\input{vtable}} 161 \end{tabular} 162 \lstMakeShortInline@ 163 \end{flushleft} 152 164 % A type's ancestors are its parent and its parent's ancestors. 153 165 % The root type has no ancestors. 154 166 % A type's descendants are its children and its children's descendants. 155 156 Every virtual type also has a list of virtual members. Children inherit 167 Every virtual type also has a pointer to a virtual table with list of virtual members. Children inherit 157 168 their parent's list of virtual members but may add new members to it. 158 It is important to note that these are virtual members, not virtual methods 159 of object-orientated programming, and can be of any type. 169 For example, 170 \begin{cfa} 171 vtable W0 | { int ?<?( int, int ); int ?+?( int, int ); } 172 vtable W1 | { int w, int ?==?( int, int ); int ?-?( int, int ); } 173 \end{cfa} 174 creates a virtual table for @W0@ initialized with the matching @<@ and @+@ 175 operations visible at this declaration. Similarly, @W1@ is initialized with 176 @<@ and @+@ from the inheritance with @W0@, plus the @==@ and @-@ operations 177 visible at this declaration. It is important to note that these are virtual 178 members, not virtual methods of object-orientated programming, and can be of 179 any type. 160 180 161 181 \PAB{Need to look at these when done.
Note: See TracChangeset
for help on using the changeset viewer.