Unit 02 of 02
Basic Syntax
A type's carried value ranges and conversion rules, a variable's scope and storage duration being separate questions, operators changing meaning by type, control flow forms, a function's declaration being separated from its definition, an array and a string resting on the same mechanism, a record type's memory layout, and input and output running through format strings.
Published Updated
Lessons
- 01 Data Types A type's value range, the signed–unsigned distinction and integer promotion being decided at the compiler stage; no size is printed except sizeof(char) == 1. 14 min read
- 02 Variables, Scope and Storage Duration Where a name is visible from being decided at compile time, and how long a value lives being decided at runtime; whether the same name falls into two separate objects in two units being resolved by the linker. 13 min read
- 03 Operators An operator's result being decided at compile time according to the operands' types; measured through precedence, short-circuit evaluation, compound assignment, and the defined–undefined distinction in evaluation order. 13 min read
- 04 Control Flow Which code path a branch follows being determined by data produced at runtime; switch fall-through, loop forms, goto's limited place, and the distinction between which branches exist and which one is chosen. 9 min read
- 05 Functions A call being bound to a definition in another unit being resolved at the linker stage; the declaration–definition distinction, parameter passing always being by copy, and the return value's type determining the caller side's interpretation. 13 min read
- 06 Arrays and Strings An array's element count being determined at compile time through constant folding, and a string's length being determined at runtime by scanning until the terminating byte; the array–pointer relationship measured through element value and difference without printing an address. 12 min read
- 07 Structs, Unions and Enumerations A struct's fields being laid out at compile time, a union sharing the same memory, and enumeration constants being compile-time constants; showing with a tag field that the language does not track which member of a union is valid. 13 min read
- 08 Input and Output A format string's text is known at compile time, but what it means is only known at runtime: of nine observations, one is decided at the preprocessor, two at the compiler, one at the linker, five at runtime. The bounding measurement shows that the language itself does not guarantee the match between a format string and its arguments. 10 min read