Changeset c4024b46 for doc/theses


Ignore:
Timestamp:
Apr 10, 2024, 1:10:14 PM (3 weeks ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
master
Children:
21e6da5, ab780e6
Parents:
0554c1a
Message:

more work on background chapter

File:
1 edited

Legend:

Unmodified
Added
Removed
  • doc/theses/mike_brooks_MMath/background.tex

    r0554c1a rc4024b46  
    236236\lstinput{12-16}{bkgd-carray-decay.c}
    237237As the @sizeof(x)@ meaning changed, compared with when run on a similarly-spelled local variable declaration,
    238 GCC also gives this code the warning for the first assertion:
     238@gcc@ also gives this code the warning for the first assertion:
    239239\begin{cfa}
    240240warning: 'sizeof' on array function parameter 'x' will return size of 'float *'
     
    321321This arrangement allocates @n@ elements on the @main@ stack frame for @ar@, called a \newterm{variable length array} (VLA), as well as 10 elements in the same stack frame for @b@.
    322322The variable-sized allocation of @ar@ is provided by the @alloca@ routine, which bumps the stack pointer.
    323 Note, the C standard supports VLAs, but the \CC standard does not;
     323Note, the C standard supports VLAs~\cite[\S~6.7.6.2.4]{C11} as a conditional feature, but the \CC standard does not;
    324324both @gcc@ and @g++@ support VLAs.
    325325As well, there is misinformation about VLAs, \eg VLAs cause stack failures or are inefficient.
    326326VLAs exist as far back as Algol W~\cite[\S~5.2]{AlgolW} and are a sound and efficient data type.
    327327
    328 In situations where the stack size has a small bound (coroutines or user-level threads), unbounded VLAs can overflow the stack so a heap allocation is used.
     328For high-performance applications, the stack size can be fixed and small (coroutines or user-level threads).
     329Here, VLAs can overflow the stack, so a heap allocation is used.
    329330\begin{cfa}
    330331float * ax1 = malloc( sizeof( float[n] ) );
     
    393394\section{Linked List}
    394395
     396Linked-lists are blocks of storage connected using one or more pointers.
     397The storage block is logically divided into data and links (pointers), where the links are the only component used by the list structure.
     398Since the data is opaque, list structures are often polymorphic over the data, which is normally homogeneous.
     399
    395400
    396401\section{String}
     402
     403A string is a logical sequence of symbols, where the form of the symbols can vary significantly: 7/8-bit characters (ASCII/Latin-1), or 2/4/8-byte (UNICODE) characters/symbols or variable length (UTF-8/16/32) characters.
     404A string can be read left-to-right, right-to-left, top-to-bottom, and have stacked elements (Arabic).
     405
     406An integer character constant is a sequence of one or more multibyte characters enclosed in single-quotes, as in @'x'@.
     407A wide character constant is the same, except prefixed by the letter @L@, @u@, or @U@.
     408With a few exceptions detailed later, the elements of the sequence are any members of the source character set;
     409they are mapped in an implementation-defined manner to members of the execution character set.
     410
     411A C character-string literal is a sequence of zero or more multibyte characters enclosed in double-quotes, as in @"xyz"@.
     412A UTF-8 string literal is the same, except prefixed by @u8@.
     413A wide string literal is the same, except prefixed by the letter @L@, @u@, or @U@.
     414
     415For UTF-8 string literals, the array elements have type @char@, and are initialized with the characters of the multibyte character sequence, as encoded in UTF-8.
     416For wide string literals prefixed by the letter @L@, the array elements have type @wchar_t@ and are initialized with the sequence of wide characters corresponding to the multibyte character sequence, as defined by the @mbstowcs@ function with an implementation-defined current locale.
     417For wide string literals prefixed by the letter @u@ or @U@, the array elements have type @char16_t@ or @char32_t@, respectively, and are initialized with the sequence of wide characters corresponding to the multibyte character sequence, as defined by successive calls to the @mbrtoc16@, or @mbrtoc32@ function as appropriate for its type, with an implementation-defined current locale.
     418The value of a string literal containing a multibyte character or escape sequence not represented in the executioncharacter set is implementation-defined.
     419
     420
     421Another bad C design decision is to have null-terminated strings rather than maintaining a separate string length.
     422\begin{quote}
     423Technically, a string is an array whose elements are single characters.
     424The compiler automatically places the null character @\0@ at the end of each such string, so programs can conveniently find the end.
     425This 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.
     426\end{quote}
Note: See TracChangeset for help on using the changeset viewer.