]> zdv2.bktei.com Git - BK-2023-05.git/blob - src/notes.tm
feat(src/notes.tm):Add TeXmacs file for personal notes
[BK-2023-05.git] / src / notes.tm
1 <TeXmacs|2.1.1>
2
3 <style|<tuple|book|style-bk>>
4
5 <\body>
6 <chapter|Definitions>
7
8 <section|Terminology>
9
10 <\description-compact>
11 <item*|declaration<label|term declaration>>A construct that establishes
12 an association between a particular variable, function, or type and its
13 attributes. (See <hlink|cppreference.com|https://en.cppreference.com/w/c/language/declarations>
14 and <hlink|microsoft.com|https://docs.microsoft.com/en-us/cpp/c-language/c-declarations-and-definitions>).
15 Compare with <with|font-series|bold|definition>.
16
17 <item*|definition<label|term definition>>A construct that stablishes the
18 same associations as a declaration but also causes storage to be
19 allocated for the variable. (See <hlink|microsoft.com|https://docs.microsoft.com/en-us/cpp/c-language/c-declarations-and-definitions>).
20
21 <item*|enumeration<label|term enumeration>><hlink|Enumeration|https://en.wikipedia.org/wiki/Enumeration>
22 (or <code*|enum>) is a user defined data type in <name|C>. It is mainly
23 used to assign names to integral constants. For example, the declaration
24 <code*|enum year{Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov,
25 Dec};> allows writing a for loop with names of months <code*|for (i=Jan;
26 i\<less\>=Dec; i++)> to cycle <code*|i> through the integers <code*|0, 1,
27 2, 3, <text-dots>, 10, 11>.
28
29 <item*|escape sequence<label|term escape_sequence>>A set of characters
30 used to represent hard-to-type or invisible characters. Some commonly
31 used escape sequences in <name|C> include:
32
33 <\description-paragraphs>
34 <item*|<cpp|\\n>>Represents the <em|newline> character.
35
36 <item*|<cpp|\\t>>Represents the <em|tab> character.
37
38 <item*|<cpp|\\b>>Represents the <em|backspace> character.
39
40 <item*|<cpp|\\\\>>Represents the <em|backslash> (i.e.
41 \P<verbatim|<em|\\>>\Q) character.
42 </description-paragraphs>
43
44 All other escape sequences used in <name|C> are:
45
46 <\description-paragraphs>
47 <item*|<cpp|\\a>>Represents the <em|alert> (bell) character.
48
49 <item*|<cpp|\\f>>Represents the <em|formfeed> character.
50
51 <item*|<cpp|\\r>>Represents the <em|carriage return> character.
52
53 <item*|<cpp|\\t>>Represents the <em|horizontal tab> character.
54
55 <item*|<cpp|\\v>>Represents the <em|vertical tab> character.
56
57 <item*|<cpp|\\?>>Represents the <em|question mark> character.
58
59 <item*|<cpp|\\'>>Represents the <em|single quote> character.
60
61 <item*|<cpp|\\">>Represents the <em|double quote> character.
62
63 <item*|<cpp|\\><em|ooo>>Represents an <em|octal number> (e.g.
64 <cpp|\\012> is the <em|newline> character<\footnote>
65 <label|ref includehelp-oct-hex>See
66 <hlinkv|https://www.includehelp.com/c/octal-and-hexadecimal-escape-sequences.aspx>.
67 </footnote>).
68
69 <item*|<cpp|\\x><em|hh>>Represents a <em|hexadecimal> number (e.g.
70 <cpp|\\x0A> is the <em|newline> character<rsup|<reference|ref
71 includehelp-oct-hex>>).
72 </description-paragraphs>
73
74 <label|term garbage_collection><item*|garbage collection>The process of
75 freeing memory allocated by a program but which is no longer referenced.
76 Usually incurs a significant <hlink|speed
77 penalty|https://en.wikipedia.org/wiki/Overhead_(computing)>.
78 (<hlink|Wikipedia|https://en.wikipedia.org/wiki/Garbage_collection_(computer_science)>).
79 The <name|C> Language does not provide garbage collection by default.
80
81 <item*|<label|term heap>heap>A large pool of memory that can be used
82 dynamically \U it is also known as the \Pfree store\Q. This is memory
83 that is not automatically managed \U you have to explicitly allocate
84 (using functions such as malloc), and deallocate (e.g. free) the memory.
85 Failure to free the memory when you are finished with it will result in
86 what is known as a memory leak. Is the diametrical opposite of the stack
87 (which, by contrast, is limited not by physical memory but by a
88 CPU-determined stack size). (See <hlink|craftofcoding.wordpress.com|https://craftofcoding.wordpress.com/2015/12/07/memory-in-c-the-stack-the-heap-and-static/>).
89
90 <item*|<label|term machine-independent>machine-independent>A property of
91 code that does not have to be modified in order to run on a different
92 hardware architecture. (e.g. \PC is called a portable language because
93 [code written in C] will run on any machine which supports C, without
94 modifying a single line of code.\Q; <hlink|link|https://www.log2base2.com/C/basic/introduction-to-c-language.html>).
95
96 <item*|<label|term operand>operand>A quantity to which an operator is
97 applied. (e.g. in the <name|C> math expression <code*|7 - 4 = 3>,
98 <code*|7> is the first operand and <code*|4> is the second operand.)
99
100 <item*|<label|term operator>operator>A special type of function with
101 limited numbers of parameters (e.g. 1 to 2) and syntax often requiring a
102 set of characters different from those normally use for naming variables
103 (e.g. the <code*|+> character in <code*|myVar = 1 + 2>, the <code*|&&> in
104 <code*|a && b>, or the <code*|++> in <code*|i++>.).
105
106 <item*|<label|term stack>stack>A region of memory for global variable
107 storage and is permanent for the entire run of the program. Stack size is
108 limited not by physical memory availability but by the CPU. Lifetime of
109 local variables declared within the stack is enforced by the Last-In,
110 First-Out nature of the stack; when a function returns a value, all stack
111 memory allocated by declarations within the function is automatically
112 freed. (See <hlink|craftofcoding.wordpress.com|https://craftofcoding.wordpress.com/2015/12/07/memory-in-c-the-stack-the-heap-and-static/>)
113
114 <item*|<label|term struct>struct>(short:
115 <hlink|struct|https://en.wikipedia.org/wiki/struct_(C_programming_language)>)
116 a <hlink|composite data type|https://en.wikipedia.org/wiki/Composite_data_type>
117 that defines a physically grouped list of variables under one name in a
118 block of memory, allowing the different variables to be accessed via a
119 single <hlink|pointer|https://en.wikipedia.org/wiki/Pointer_(computer_programming)>
120 or by the struct declared name which returns the same address.
121
122 <label|term structure_assignment><item*|structure assignment>The act of
123 <hlink|assigning|https://en.wikipedia.org/wiki/Assignment_(computer_science)>
124 a <hlink|struct|https://en.wikipedia.org/wiki/struct_(C_programming_language)>
125 to another struct. (?) (<hlink|example|https://stackoverflow.com/a/2302359/10850071>)
126
127 <item*|<label|term text_stream>text stream>A sequence of characters
128 divided into lines; each line consists of zero or more characters
129 followed by a newline character. (See K&R 2nd Ed. Section 1.5 \PCharacter
130 Input and Output\Q)
131 </description-compact>
132
133 \;
134
135 <section|Functions>
136
137 <subsection|Character Input and Output>
138
139 <\description>
140 <item*|<cpp|getchar()><label|func getchar>>Read one character at a time.
141
142 <item*|<cpp|for()>>A generalization of <cpp|while()>. Takes three
143 arguments:
144
145 <\enumerate>
146 <item>Local statement to run before loop (e.g. to initialize a counting
147 variable).
148
149 <item>Local statement that, if evaluated as true, permits running of
150 next iteration of loop.
151
152 <item>Local statement to run after loop (e.g. to increment a counting
153 variable).
154 </enumerate>
155
156 <item*|<cpp|putchar()><label|func putchar>>Write one character at a time.
157
158 <item*|<cpp|printf()>>Used for printing formatted text to console.
159 </description>
160
161 \;
162
163 \;
164
165 \;
166 </body>
167
168 <\initial>
169 <\collection>
170 <associate|preamble|false>
171 </collection>
172 </initial>
173
174 <\references>
175 <\collection>
176 <associate|auto-1|<tuple|1|?>>
177 <associate|auto-2|<tuple|1.1|?>>
178 <associate|auto-3|<tuple|1.2|?>>
179 <associate|auto-4|<tuple|1.2.1|?>>
180 <associate|footnote-1.1.1|<tuple|1.1.1|?>>
181 <associate|footnote-1.1.2|<tuple|1.1.2|?>>
182 <associate|footnr-1.1.1|<tuple|1.1.1|?>>
183 <associate|footnr-1.1.2|<tuple|1.1.2|?>>
184 <associate|func getchar|<tuple|1.2.1|?>>
185 <associate|func putchar|<tuple|3|?>>
186 <associate|ref includehelp-oct-hex|<tuple|1.1.1|?>>
187 <associate|term declaration|<tuple|1.1|?>>
188 <associate|term definition|<tuple|declaration<label|term declaration>|?>>
189 <associate|term enumeration|<tuple|definition<label|term definition>|?>>
190 <associate|term escape_sequence|<tuple|enumeration<label|term
191 enumeration>|?>>
192 <associate|term foo|<tuple|structure assignment|?>>
193 <associate|term garbage_collection|<tuple|1.1.1|?>>
194 <associate|term heap|<tuple|garbage collection|?>>
195 <associate|term machine-independent|<tuple|<label|term heap>heap|?>>
196 <associate|term operand|<tuple|<label|term
197 machine-independent>machine-independent|?>>
198 <associate|term operator|<tuple|<label|term operand>operand|?>>
199 <associate|term stack|<tuple|<label|term operator>operator|?>>
200 <associate|term struct|<tuple|<label|term stack>stack|?>>
201 <associate|term structure_assignment|<tuple|<label|term struct>struct|?>>
202 <associate|term text_stream|<tuple|structure assignment|?>>
203 <associate|term-sep XX|<tuple|structure assignment|?>>
204 </collection>
205 </references>
206
207 <\auxiliary>
208 <\collection>
209 <\associate|toc>
210 <vspace*|1fn><with|font-series|<quote|bold>|math-font-series|<quote|bold>|1<space|2spc>Definitions>
211 <datoms|<macro|x|<repeat|<arg|x>|<with|font-series|medium|<with|font-size|1|<space|0.2fn>.<space|0.2fn>>>>>|<htab|5mm>>
212 <no-break><pageref|auto-1><vspace|0.5fn>
213
214 1.1<space|2spc>Terminology <datoms|<macro|x|<repeat|<arg|x>|<with|font-series|medium|<with|font-size|1|<space|0.2fn>.<space|0.2fn>>>>>|<htab|5mm>>
215 <no-break><pageref|auto-2>
216
217 1.2<space|2spc>Functions <datoms|<macro|x|<repeat|<arg|x>|<with|font-series|medium|<with|font-size|1|<space|0.2fn>.<space|0.2fn>>>>>|<htab|5mm>>
218 <no-break><pageref|auto-3>
219
220 <with|par-left|<quote|1tab>|1.2.1<space|2spc>Character Input and Output
221 <datoms|<macro|x|<repeat|<arg|x>|<with|font-series|medium|<with|font-size|1|<space|0.2fn>.<space|0.2fn>>>>>|<htab|5mm>>
222 <no-break><pageref|auto-4>>
223 </associate>
224 </collection>
225 </auxiliary>