source: doc/theses/mike_brooks_MMath/list.tex @ 830edc6

Last change on this file since 830edc6 was 123e8b9, checked in by Peter A. Buhr <pabuhr@…>, 7 months ago

move background material from list chapter to background chapter

  • Property mode set to 100644
File size: 5.0 KB
RevLine 
[5717495]1\chapter{Linked List}
2
3I wrote a linked-list library for \CFA.  This chapter describes it.
4
5The library provides a doubly-linked list that
6attaches links intrusively,
7supports multiple link directions,
8integrates with user code via the type system,
9treats its ends uniformly, and
10identifies a list using an explicit head.
11
12TODO: more summary
13
14
15
16\section{Features}
17
18\subsection{Core Design Issues}
19
20This section reviews how a user experiences my \CFA list library's position on the issues of Section~\ref{toc:lst:issue}.
21The library provides a doubly-linked list that
22attaches links intrusively,
23supports multiple link directions,
24integrates with user code via the type system,
25treats its ends uniformly, and
26identifies a list using an explicit head.
27
[5d9c4bb]28The \CFA list library's version of the running @req@ example is in Figure~\ref{fig:lst-features-intro}.
29Its link attachment is intrusive and the resulting memory layout is pure-stack, just as for the LQ version of Figure~\ref{f:Intrusive}.
30The framework-provided type @dlink(...)@ provides the links.
31The user inserts the links into the @req@ structure by using \CFA inline-inheritance (TODO: reference introduction).
32Inline inheritance means the type of the field is @dlink(req)@, the field is unnamed, a reference to a @req@ is implicitly convertible to @dlink@.\footnote{
33    The \CFA list examples elide the \lstinline{P9_EMBEDDED} annotations that (TODO: xref P9E future work) proposes to obviate.
34    Thus, these examples illustrate a to-be state, free of what is to be historic clutter.
35    The elided portions are immaterial to the discussion and the examples work with the annotations provided.
36    The \CFA test suite (TODO:cite?) includes equivalent demonstrations, with the annotations included.}
37These links have a nontrivial, user-specified location within the @req@ structure;
38this convention encapsulates the implied pointer arithmetic safely.
[5717495]39
40\begin{figure}
[b64d0f4]41    \lstinput{20-32}{lst-features-intro.run.cfa}
[5717495]42    \caption[Multiple link directions in \CFA list library]{
[5d9c4bb]43        Demonstration of the running \lstinline{req} example, done using the \CFA list library.
[5717495]44        This example does the same job that Figure~\ref{fig:lst-issues-attach} shows three ways.
45    }
[5d9c4bb]46    \label{fig:lst-features-intro}
[5717495]47\end{figure}
48
49\begin{figure}
[5d9c4bb]50\centering
51\begin{tabular}{@{}ll@{}}
52\begin{tabular}{@{}l@{}}
[b64d0f4]53    \lstinput{20-25}{lst-features-multidir.run.cfa} \\
54    \lstinput{40-67}{lst-features-multidir.run.cfa}
[5d9c4bb]55    \end{tabular}
56        &
[b64d0f4]57        \lstinput[language=C++]{20-60}{lst-issues-multi-static.run.c}
[5d9c4bb]58        \end{tabular}
59
60\caption{
[5717495]61        Demonstration of multiple static link directions done in the \CFA list library.
62        This example does the same job as Figure~\ref{fig:lst-issues-multi-static}.
63    }
[5d9c4bb]64    \label{fig:lst-features-multidir}
[5717495]65\end{figure}
66
[5d9c4bb]67Figure~\ref{fig:lst-features-multidir} shows how the \CFA library supports multi-static link directionality.
[5717495]68The declaration of @req@ now has two inline-inheriting @dlink@ occurrences.
[5d9c4bb]69The first of these lines gives a type named @req.by_pri@, @req@ inherits from it, and it inherits from @dlink@.
70The second line @req.by_rqr@ is similar to @req.by_pri@.
[5717495]71Thus, there is a diamond, non-virtual, inheritance from @req@ to @dlink@, with @by_pri@ and @by_rqr@ being the mid-level types.
72Disambiguation occurs in the declarations of the list-head objects.
73The type of the variable @reqs_pri_global@ is @dlist(req, req.by_pri)@,
74meaning operations called on @reqs_pri_global@ are implicitly disambiguated.
[5d9c4bb]75In the example, the calls @insert_first(reqs_pri_global, ...)@ imply, ``here, we are working by priority.''
[5717495]76
77The \CFA library also supports the common case, of single directionality, more naturally than LQ. 
78Figure~\ref{fig:lst-features-intro} shows a single-direction list done with no contrived name for the link direction,
[5d9c4bb]79where Figure~\ref{f:Intrusive} adds the unnecessary name, @x@.
[5717495]80In \CFA, a user doing a single direction (Figure~\ref{fig:lst-features-intro})
[5d9c4bb]81sets up a simple inheritance with @dlink@, and declares a list head to have the simpler type @dlist(...)@.
[5717495]82While a user doing multiple link directions (Figure~\ref{fig:lst-features-multidir})
[5d9c4bb]83sets up a diamond inheritance with @dlink@, and declares a list head to have the more-informed type @dlist(..., DIR)@.
[5717495]84
85The \CFA library offers a type-system mediated integration with user code.
86The examples presented do not use preprocessor macros.
87The touchpoints @dlink@ and @dlist@ are ordinary types.
88Even though they are delivered as header-included static-inline implementations,
89the \CFA compiler typechecks the list library code separately from user code.
90Errors in user code are reported only with mention of the library's declarations.
91
92The \CFA library works in headed and headless modes.  TODO: elaborate.
93
94\subsection{Iteration-FOUNDATIONS}
95
96TODO: This section should be moved to a Foundations chapter.  The next section stays under Linked List.
97
98
99\subsection{Iteration}
100
101
102\section{Future Work}
103\label{toc:lst:futwork}
104
105
106TODO: deal with: A doubly linked list is being designed.
107
108TODO: deal with: Link fields are system-managed.
109Links in GDB.
110
Note: See TracBrowser for help on using the repository browser.