]> zdv2.bktei.com Git - BK-2023-05.git/blobdiff - src/notes.tm
feat(src/kr/ch1/s1.7):Add power function example
[BK-2023-05.git] / src / notes.tm
index 0d4cac65d7c447da26bf10a84a3094b2b31007e4..ebe2879f1d8309d422d36b54ff656c4d006e36f1 100644 (file)
   <section|Terminology>
 
   <\description-compact>
+    <item*|argument<label|term_argument>>A value used to supply a
+    <strong|parameter> in the call of a <strong|function>. Also known as an
+    \Pactual argument\Q as opposed to \Pformal argument\Q (i.e.
+    <strong|parameter>). See also <em|parameter>.
+
     <item*|assignment>An expression in which a variable is set to a value.
     For example, in the expression <hgroup|<cpp|x = 1>>, the variable <cpp|x>
     is set to the value <cpp|1> because <cpp|x> is to the left of the equals
       a = ( b = ( c = 0 ) );
     </cpp-code>
 
+    <item*|call>The act of running (or \Pinvoking\Q) a <strong|function>. See
+    <em|function call>.
+
     <item*|declaration<label|term declaration>>A construct that establishes
     an association between a particular variable, function, or type and its
-    attributes. (See <hlink|cppreference.com|https://en.cppreference.com/w/c/language/declarations>
-    and <hlink|microsoft.com|https://docs.microsoft.com/en-us/cpp/c-language/c-declarations-and-definitions>).
-    Compare with <with|font-series|bold|definition>.
-
-    <item*|definition<label|term definition>>A construct that stablishes the
+    attributes<\footnote>
+      See <hlinkv|https://en.cppreference.com/w/c/language/declarations>.
+    </footnote>. Announces the properties of variables. May be a statement
+    consisting of a <strong|type> name followed by a list of
+    <strong|variables> (e.g. <cpp|int i, j;>) or followed by an expression
+    with a variable (e.g. <cpp|int i = 0;>). Compare with
+    <with|font-series|bold|definition>.
+
+    <item*|definition<label|term definition>>A construct that establishes the
     same associations as a declaration but also causes storage to be
-    allocated for the variable. (See <hlink|microsoft.com|https://docs.microsoft.com/en-us/cpp/c-language/c-declarations-and-definitions>).
+    allocated for the variable<\footnote>
+      See <hlinkv|https://docs.microsoft.com/en-us/cpp/c-language/c-declarations-and-definitions?view=msvc-170>.
+    </footnote>.
+
+    <item*|delinter><label|term_delinter> A source code analysis program
+    designed to detect common syntactic errors.
 
     <item*|enumeration<label|term enumeration>><hlink|Enumeration|https://en.wikipedia.org/wiki/Enumeration>
     (or <code*|enum>) is a user defined data type in <name|C>. It is mainly
       includehelp-oct-hex>>).
     </description-aligned>
 
+    <label|term_expression><item*|expression> A sequence of
+    <strong|operators> and <strong|operands> that specify a computation. When
+    evaluated, an expression may perform useful side effects (e.g.
+    <cpp|printf("%d", 4)> sends the character <cpp|4> to \ the standard
+    output stream)<\footnote>
+      See <hlinkv|https://en.cppreference.com/w/c/language/expressions>.
+    </footnote>.
+
+    Arrangements of expressions may include<\footnote>
+      See <hlinkv|https://www.educative.io/answers/what-are-expressions-in-c>.
+    </footnote>:
+
+    <\description>
+      <item*|Constant>A value with no operator is used<\footnote>
+        See <hlinkv|https://www.cs.miami.edu/home/burt/learning/Math120.1/Notes/exp-syn.html>.
+      </footnote>. (e.g. the \P<cpp|0>\Q in <cpp|return 0;>)
+
+      <item*|Variable identifier>A variable evaluated earlier. (e.g. the 2nd
+      \P<cpp|k>\Q in <hgroup|<cpp|k = 1; return k;>>)
+
+      <item*|Infix expression>Operator is used between operands. (e.g. <cpp|a
+      = x + y>)
+
+      <item*|Postfix expression>Operator is used after the operands. (e.g.
+      <cpp|xy+>)
+
+      <item*|Prefix expression>Operator is used before the operands. (e.g.
+      <cpp|+xy>)
+
+      <item*|Unary expression>There is one operator and one operand. (e.g.
+      <cpp|x++>)
+
+      <item*|Binary expression>There is one operator and two operands. (e.g.
+      <cpp|x+y>)
+    </description>
+
+    Types of expressions may include:
+
+    <\description>
+      <item*|Arithmetic expression>Consists of arithmetic operators (<cpp|+,
+      -, *, and />) and computes values of <cpp|int, float, or double> type.
+
+      <item*|Relational expression>Usually uses comparison operators
+      (<cpp|\<gtr\>, \<less\>, \<gtr\>=, \<less\>=, ===, and !==>) and
+      computers answer in the <cpp|bool> type (i.e. true \P<cpp|1>\Q or false
+      \P<cpp|0>\Q).
+
+      <item*|Logical expression>Consists of logical operators (<cpp|&&, \|\|,
+      and !>) and combines relational expressions to compute answers in the
+      <cpp|bool> type.
+
+      <item*|Conditional expression>Consists of statements that return
+      <cpp|true> if the condition is met or <cpp|false> otherwise.
+
+      <item*|Pointer expression>May consist of an ampersand (<cpp|&>)
+      operator and returns <cpp|address> values.
+
+      <item*|Bitwise expression>Consists of bitwise operators
+      (<cpp|\<gtr\>\<gtr\>, \<less\>\<less\>, ~, &, \|, and ^>) and performs
+      operations at the bit level.
+
+      <item*|Constant expression>Involves only constants such that the
+      expression may be evaluated during compilation rather than
+      run-time<\footnote>
+        K&R 2nd Ed., Sec. 2.3 \PConstants\Q.
+      </footnote>.
+    </description>
+
+    <label|term_function><item*|function>A group of statements that perform a
+    task. Is defined using a function <strong|definition> that has a
+    parenthesized list of <strong|declarations> called <strong|parameters>
+    (e.g. variables for accepting values named <strong|arguments> as input
+    when the <strong|function> is called). A function definition has the
+    form:
+
+    <em|<\indent>
+      return-type<space|1em>function-name(parameter declarations, if any) {
+
+      <space|1em>declarations
+
+      <space|1em>statements
+
+      }
+    </indent>>
+
+    <item*|function call>An expression containing the <strong|function> name
+    followed by the function call operator \P<cpp|()>\Q.
+
     <label|term garbage_collection><item*|garbage collection>The process of
     freeing memory allocated by a program but which is no longer referenced.
     Usually incurs a significant <hlink|speed
     (e.g. the <code*|+> character in <code*|myVar = 1 + 2>, the <code*|&&> in
     <code*|a && b>, or the <code*|++> in <code*|i++>.).
 
+    <label|term_parameter><item*|parameter>Generally, a variable named in the
+    parenthesized list in a <strong|function> definition. Also known as a
+    \Pformal argument\Q as opposed to an \Pactual argument\Q (e.g.
+    <strong|argument>). See <em|argument>.
+
     <item*|<label|term stack>stack>A region of memory for global variable
     storage and is permanent for the entire run of the program. Stack size is
     limited not by physical memory availability but by the CPU. Lifetime of
     memory allocated by declarations within the function is automatically
     freed. (See <hlink|craftofcoding.wordpress.com|https://craftofcoding.wordpress.com/2015/12/07/memory-in-c-the-stack-the-heap-and-static/>)
 
+    <label|term_statement><item*|statement>An <strong|expression> when it is
+    followed by a semicolon. May be grouped together using braces (i.e.
+    \P<cpp|{ }>\Q) to form a <em|compound statement> or <em|block> which is
+    syntactically equivalent to a single <strong|statement>.<\footnote>
+      K&R 2nd Ed., Sec. 3.1 \PStatements and Blocks\Q.
+    </footnote>
+
     <item*|<label|term struct>struct>(short:
     <hlink|struct|https://en.wikipedia.org/wiki/struct_(C_programming_language)>)
     a <hlink|composite data type|https://en.wikipedia.org/wiki/Composite_data_type>
     divided into lines; each line consists of zero or more characters
     followed by a newline character. (See K&R 2nd Ed. Section 1.5 \PCharacter
     Input and Output\Q)
+
+    <item*|type>A way of differentiating data stored for use in a program.
+    Some types include <cpp|int> (integers), <cpp|char> (single-byte
+    characters), <cpp|short> (a short integer), <cpp|long> (a long integer),
+    <cpp|double> (a double-precision floating point number).
   </description-compact>
 
   \;
     Character codes include:
 
     <\description-aligned>
+      <item*|<cpp|%c>>Used to display a character by its <cpp|int>.
+
       <item*|<cpp|%d>>Used with <cpp|int> (i.e. 16-bit integers; max value of
       <math|2<rsup|16>=32\<space\>767>).
 
       <item*|<cpp|%f>>Used with <cpp|float> and <cpp|double> (double
       precision <cpp|float>).
     </description-aligned>
+
+    For printing <name|UTF-8> strings (which are multibyte in contrast to
+    one-byte <name|ASCII> strings), functions from the C standard library
+    <cpp|wchar.h> header file<\footnote>
+      See <hlinkv|https://en.wikibooks.org/wiki/C_Programming/wchar.h>.
+    </footnote> may need to be<\footnote>
+      See <hlinkv|https://linuxprograms.wordpress.com/tag/c-utf-8-handling/>.
+    </footnote> used<\footnote>
+      See <hlinkv|https://stackoverflow.com/questions/56756204/compatibility-of-printf-with-utf-8-encoded-strings>.
+    </footnote> (e.g. <cpp|wprintf()> (?)).
   </description>
 
   \;
 
-  \;
+  <chapter|Utilities>
+
+  <section|Text Editor>
+
+  <\itemize>
+    <item><name|Emacs> - GNU text editor. See
+    <hlinkv|https://www.gnu.org/software/emacs/>.
+
+    <item><name|Vim> - text editor See <hlinkv|https://www.vim.org/>.
+  </itemize>
+
+  <section|Linter>
+
+  (TODO: Insert C language linter here)
 
   \;
 </body>
     <associate|auto-2|<tuple|1.1|?>>
     <associate|auto-3|<tuple|1.2|?>>
     <associate|auto-4|<tuple|1.2.1|?>>
-    <associate|footnote-1|<tuple|1|?>>
+    <associate|auto-5|<tuple|2|?>>
+    <associate|auto-6|<tuple|2.1|?>>
+    <associate|auto-7|<tuple|2.2|?>>
     <associate|footnote-1.1.1|<tuple|1.1.1|?>>
+    <associate|footnote-1.1.2|<tuple|1.1.2|?>>
+    <associate|footnote-1.1.3|<tuple|1.1.3|?>>
+    <associate|footnote-1.1.4|<tuple|1.1.4|?>>
+    <associate|footnote-1.1.5|<tuple|1.1.5|?>>
+    <associate|footnote-1.1.6|<tuple|1.1.6|?>>
+    <associate|footnote-1.1.7|<tuple|1.1.7|?>>
+    <associate|footnote-1.1.8|<tuple|1.1.8|?>>
     <associate|footnote-1.2.1|<tuple|1.2.1|?>>
     <associate|footnote-1.2.2|<tuple|1.2.2|?>>
+    <associate|footnote-1.2.3|<tuple|1.2.3|?>>
+    <associate|footnote-1.2.4|<tuple|1.2.4|?>>
+    <associate|footnote-1.2.5|<tuple|1.2.5|?>>
     <associate|footnr-1.1.1|<tuple|1.1.1|?>>
+    <associate|footnr-1.1.2|<tuple|1.1.2|?>>
+    <associate|footnr-1.1.3|<tuple|1.1.3|?>>
+    <associate|footnr-1.1.4|<tuple|1.1.4|?>>
+    <associate|footnr-1.1.5|<tuple|1.1.5|?>>
+    <associate|footnr-1.1.6|<tuple|1.1.6|?>>
+    <associate|footnr-1.1.7|<tuple|1.1.7|?>>
+    <associate|footnr-1.1.8|<tuple|1.1.8|?>>
     <associate|footnr-1.2.1|<tuple|1.2.1|?>>
     <associate|footnr-1.2.2|<tuple|1.2.2|?>>
+    <associate|footnr-1.2.3|<tuple|1.2.3|?>>
+    <associate|footnr-1.2.4|<tuple|1.2.4|?>>
+    <associate|footnr-1.2.5|<tuple|1.2.5|?>>
     <associate|func getchar|<tuple|1.2.1|?>>
     <associate|func putchar|<tuple|3|?>>
-    <associate|ref includehelp-oct-hex|<tuple|1.1.1|?>>
-    <associate|term declaration|<tuple|assignment|?>>
-    <associate|term definition|<tuple|declaration<label|term declaration>|?>>
-    <associate|term enumeration|<tuple|definition<label|term definition>|?>>
+    <associate|ref includehelp-oct-hex|<tuple|1.1.3|?>>
+    <associate|term declaration|<tuple|call|?>>
+    <associate|term definition|<tuple|1.1.1|?>>
+    <associate|term enumeration|<tuple|delinter|?>>
     <associate|term escape_sequence|<tuple|enumeration<label|term
     enumeration>|?>>
-    <associate|term garbage_collection|<tuple|<with|mode|<quote|prog>|prog-language|<quote|cpp>|font-family|<quote|rm>|\\x><with|font-shape|<quote|italic>|hh>|?>>
+    <associate|term garbage_collection|<tuple|function call|?>>
     <associate|term heap|<tuple|garbage collection|?>>
     <associate|term machine-independent|<tuple|<label|term heap>heap|?>>
     <associate|term operand|<tuple|<label|term
     machine-independent>machine-independent|?>>
     <associate|term operator|<tuple|<label|term operand>operand|?>>
-    <associate|term stack|<tuple|<label|term operator>operator|?>>
-    <associate|term struct|<tuple|<label|term stack>stack|?>>
+    <associate|term stack|<tuple|parameter|?>>
+    <associate|term struct|<tuple|1.1.8|?>>
     <associate|term structure_assignment|<tuple|<label|term struct>struct|?>>
     <associate|term text_stream|<tuple|structure assignment|?>>
+    <associate|term_argument|<tuple|1.1|?>>
+    <associate|term_delinter|<tuple|delinter|?>>
+    <associate|term_expression|<tuple|<with|mode|<quote|prog>|prog-language|<quote|cpp>|font-family|<quote|rm>|\\x><with|font-shape|<quote|italic>|hh>|?>>
+    <associate|term_function|<tuple|1.1.7|?>>
+    <associate|term_parameter|<tuple|<label|term operator>operator|?>>
+    <associate|term_statement|<tuple|<label|term stack>stack|?>>
+    <associate|term_variable|<tuple|<label|term text_stream>text stream|?>>
   </collection>
 </references>
 
       <with|par-left|<quote|1tab>|1.2.1<space|2spc>Character Input and Output
       <datoms|<macro|x|<repeat|<arg|x>|<with|font-series|medium|<with|font-size|1|<space|0.2fn>.<space|0.2fn>>>>>|<htab|5mm>>
       <no-break><pageref|auto-4>>
+
+      <vspace*|1fn><with|font-series|<quote|bold>|math-font-series|<quote|bold>|2<space|2spc>Utilities>
+      <datoms|<macro|x|<repeat|<arg|x>|<with|font-series|medium|<with|font-size|1|<space|0.2fn>.<space|0.2fn>>>>>|<htab|5mm>>
+      <no-break><pageref|auto-5><vspace|0.5fn>
+
+      2.1<space|2spc>Text Editor <datoms|<macro|x|<repeat|<arg|x>|<with|font-series|medium|<with|font-size|1|<space|0.2fn>.<space|0.2fn>>>>>|<htab|5mm>>
+      <no-break><pageref|auto-6>
+
+      2.2<space|2spc>Linter <datoms|<macro|x|<repeat|<arg|x>|<with|font-series|medium|<with|font-size|1|<space|0.2fn>.<space|0.2fn>>>>>|<htab|5mm>>
+      <no-break><pageref|auto-7>
     </associate>
   </collection>
 </auxiliary>
\ No newline at end of file