- Timestamp:
- Oct 9, 2024, 5:34:18 PM (5 weeks ago)
- Branches:
- master
- Children:
- 0766399
- Parents:
- 1b770e40
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/theses/mike_brooks_MMath/intro.tex
r1b770e40 r7d415b4 3 3 All modern programming languages provide three high-level containers (collections): array, linked-list, and string. 4 4 Often array is part of the programming language, while linked-list is built from (recursive) pointer types, and string from a combination of array and linked-list. 5 For all three types, languages supply varying degrees of high-level mechanism for manipulating these objects at the bulk level and at the component level, such as array copy, slicing and iterating .5 For all three types, languages supply varying degrees of high-level mechanism for manipulating these objects at the bulk level and at the component level, such as array copy, slicing and iterating using subscripting. 6 6 7 7 This work looks at extending these three foundational container types in the programming language \CFA, which is a new dialect of the C programming language. 8 8 A primary goal of \CFA~\cite{Cforall} is 99\% backward compatibility with C, while maintaining a look and feel that matches with C programmer experience and intuition. 9 9 This goal requires ``thinking inside the box'' to engineer new features that ``work and play'' with C and its massive legacy code-base. 10 An additionalgoal is balancing good performance with safety.10 An equally important goal is balancing good performance with safety. 11 11 12 12 … … 14 14 15 15 An array provides a homogeneous container with $O(1)$ access to elements using subscripting. 16 Higher-level operations like array slicing (single or multidimensional) may have significantly higher cost, but provides a better programmer experience. 16 17 The array size can be static, dynamic but fixed after creation, or dynamic and variable after creation. 17 18 For static and dynamic-fixed, an array can be stack allocated, while dynamic-variable requires the heap. … … 30 31 \section{String} 31 32 32 A string provides a dynamic array of homogeneous elements, where the elements are oftenhuman-readable characters.33 What differentiates a string from other types in that its operations work on blocks of elements for scanning and changing, \eg @index@ and @substr@.34 Subscripting individual elements is often available.35 Therefore, the cost of string operations is less important than the power of the operationsto accomplish complex text manipulation, \eg search, analysing, composing, and decomposing.33 A string provides a dynamic array of homogeneous elements, where the elements are (often) some form of human-readable characters. 34 What differentiates a string from other types in that many of its operations work on groups of elements for scanning and changing, \eg @index@ and @substr@; 35 subscripting individual elements is usually available, too. 36 Therefore, the cost of a string operation is usually less important than the power of the operation to accomplish complex text manipulation, \eg search, analysing, composing, and decomposing. 36 37 The dynamic nature of a string means storage is normally heap allocated but often implicitly managed, even in unmanaged languages. 37 Often string management is separate from heap management, \ie strings roll their own heap. 38 In some cases, string management is separate from heap management, \ie strings roll their own heap. 39 40 41 \section{Iterator} 42 43 As a side issue to working with complex structured types is iterating through them. 44 Some thought has been given to \emph{general} versus specific iteration capabilities as part of of this work, but the general iteration work is only a sketch for others as future work. 45 Nevertheless, sufficed work was done to write out the ideas that developed and how they should apply in the main context of this work. 38 46 39 47 … … 43 51 \begin{enumerate}[leftmargin=*] 44 52 \item 45 These three aspects of C are extremely difficult to understand, teach, and get right because they are correspondingly extremely low level.46 Providing higher-level versions of these containers in \CFA is a major component of the primary goal.53 These three aspects of C are difficult to understand, teach, and get right because they are correspondingly low level. 54 Providing higher-level, feature-rich versions of these containers in \CFA is a major component of the primary goal. 47 55 \item 48 56 These three aspects of C cause the greatest safety issues because there are few or no safe guards when a programmer misunderstands or misuses these features~\cite{Elliott18, Blache19, Ruef19, Oorschot23}. … … 62 70 63 71 Like many established programming languages, C has a standards committee and multiple ANSI/\-ISO language manuals~\cite{C99,C11,C18,C23}. 64 However, most programming languages are only partially explained by standard's manuals.72 However, most programming languages are only partially explained by their standard's manual(s). 65 73 When it comes to explaining how C works, the definitive source is the @gcc@ compiler, which is mimicked by other C compilers, such as Clang~\cite{clang}. 66 74 Often other C compilers must mimic @gcc@ because a large part of the C library (runtime) system (@glibc@ on Linux) contains @gcc@ features. 67 While some key aspects of C need to be explained by quoting from the language reference manual, to illustrate definite program semantics, my approach in this thesis is to devise a program, whose behaviour exercises a point at issue, and shows its behaviour.75 While some key aspects of C need to be explained and understood by quoting from the language reference manual, to illustrate actual program semantics, this thesis uses constructs a program whose behaviour exercises a particular point and then confirms the behaviour by running the program. 68 76 These example programs show 69 77 \begin{itemize}[leftmargin=*] 70 78 \item if the compiler accepts or rejects certain syntax, 71 \item prints output to buttress a claim of behaviour,79 \item prints output to buttress a behavioural claim, 72 80 \item or executes without triggering any embedded assertions testing pre/post-assertions or invariants. 73 81 \end{itemize} 74 This work has been tested across @gcc@ versions 8--1 2 and clang version 10running on ARM, AMD, and Intel architectures.82 This work has been tested across @gcc@ versions 8--14 and clang versions 10--14 running on ARM, AMD, and Intel architectures. 75 83 Any discovered anomalies among compilers or versions is discussed. 76 In all case, it is never clear whether the \emph{truth} lies in the compiler or the C standard.84 In all case, it is never clear whether the \emph{truth} lies in the compiler(s) or the C standard. 77 85 78 86 79 87 \section{Contributions} 88 89 This work has produced significant syntactic and semantic improvements to C's arrays, linked-lists and string types. 90 As well, a strong plan for general iteration has been sketched out. 80 91 81 92 \subsection{Linked list}
Note: See TracChangeset
for help on using the changeset viewer.