Changeset 4fc7388 for doc/theses/mike_brooks_MMath
- Timestamp:
- May 28, 2024, 7:55:55 AM (7 months ago)
- Branches:
- master
- Children:
- 8f7109c
- Parents:
- 703885e
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/theses/mike_brooks_MMath/background.tex
r703885e r4fc7388 714 714 \begin{c++} 715 715 uSequence<NodeDL> sequence; 716 sequence.add_front( node.nodeseq );$\C{// link fields in embedded type}$717 NodeDL nodedl = sequence.remove( node.nodeseq);718 int i = nodedl. get().i;$\C{// indirection to node}$716 sequence.add_front( @node.nodeseq@ ); $\C{// link fields in embedded type}$ 717 NodeDL nodedl = sequence.remove( @node.nodeseq@ ); 718 int i = nodedl.@get()@.i; $\C{// indirection to node}$ 719 719 \end{c++} 720 720 Hence, the \uCpp approach optimizes one set of intrusive links through the \CC inheritance mechanism, and falls back onto the LQ approach of explicit declarations for additional intrusive links. … … 803 803 Technically, a string is an array whose elements are single characters. 804 804 The compiler automatically places the null character @\0@ at the end of each such string, so programs can conveniently find the end. 805 This representation means that there is no real limit to how long a string can be, but programs have to scan one completely to determine its length. 805 This representation means that there is no real limit to how long a string can be, but programs have to scan one completely to determine its length.~\cite[p.~36]{C:old} 806 806 \end{quote} 807 807 Unfortunately, this design decision is both unsafe and inefficient. 808 It is common error in C to forget the s pace in a character array for the terminator or overwrite the terminator, resulting in array overruns in string operations.808 It is common error in C to forget the storage in a character array for the terminator or overwrite the terminator, resulting in array overruns in string operations. 809 809 The need to repeatedly scan an entire string to determine its length can result in significant cost, as it is impossible to cache the length in many cases. 810 810 811 811 C strings are fixed size because arrays are used for the implementation. 812 However, string manipulation commonly results in dynamically-sized temporary and final string values .812 However, string manipulation commonly results in dynamically-sized temporary and final string values, \eg @strcpy@, @strcat@, @strcmp@, @strlen@, @strstr@, \etc. 813 813 As a result, storage management for C strings is a nightmare, quickly resulting in array overruns and incorrect results. 814 814 815 815 Collectively, these design decisions make working with strings in C, awkward, time consuming, and unsafe. 816 While there are companion string routines that take the maximum lengths of strings to prevent array overruns, that means the semantics of the operation can fail because strings are truncated.817 Suffice it to say, C is not a go-to language for string applications, which is why \CC introduced the @string@ type.816 While there are companion string routines that take the maximum lengths of strings to prevent array overruns, \eg @strncpy@, @strncat@, @strncpy@, that means the semantics of the operation can fail because strings are truncated. 817 Suffice it to say, C is not a go-to language for string applications, which is why \CC introduced the dynamically-sized @string@ type.
Note: See TracChangeset
for help on using the changeset viewer.