Ignore:
Timestamp:
Aug 12, 2021, 8:07:39 AM (3 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
93d0ed3
Parents:
b42d0ea
Message:

add virtual type examples and figure

Location:
doc/theses/andrew_beach_MMath
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • doc/theses/andrew_beach_MMath/features.tex

    rb42d0ea rbfd7b30  
    130130
    131131\section{Virtuals}
     132\label{s:Virtuals}
    132133Virtual types and casts are not part of \CFA's EHM nor are they required for
    133134an EHM.
    134135However, one of the best ways to support an exception hierarchy
    135136is via a virtual hierarchy and dispatch system.
    136 
    137137Ideally, the virtual system should have been part of \CFA before the work
    138138on exception handling began, but unfortunately it was not.
     
    149149number of children.
    150150Any type that belongs to any of these trees is called a virtual type.
    151 
     151For 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}
     156vtype V0, V1(V0), V2(V0);
     157vtype W0, W1(W0), W2(W1);
     158\end{cfa}
     159&
     160\raisebox{-0.6\totalheight}{\input{vtable}}
     161\end{tabular}
     162\lstMakeShortInline@
     163\end{flushleft}
    152164% A type's ancestors are its parent and its parent's ancestors.
    153165% The root type has no ancestors.
    154166% 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
     167Every virtual type also has a pointer to a virtual table with list of virtual members. Children inherit
    157168their 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.
     169For example,
     170\begin{cfa}
     171vtable W0 | { int ?<?( int, int ); int ?+?( int, int ); }
     172vtable W1 | { int w, int ?==?( int, int ); int ?-?( int, int ); }
     173\end{cfa}
     174creates a virtual table for @W0@ initialized with the matching @<@ and @+@
     175operations visible at this declaration.  Similarly, @W1@ is initialized with
     176@<@ and @+@ from the inheritance with @W0@, plus the @==@ and @-@ operations
     177visible at this declaration. It is important to note that these are virtual
     178members, not virtual methods of object-orientated programming, and can be of
     179any type.
    160180
    161181\PAB{Need to look at these when done.
Note: See TracChangeset for help on using the changeset viewer.