Skip to content
📖 Auto vs Modern CBook contents

Chapter 5: Basic Values & Data ​

Level 1 — Acquaintance

The foundation of all computation: types, values, and how C and Auto represent data.

This is the most important chapter in Level 1. Everything you build in C or Auto rests on understanding how the language represents values in memory. We cover the abstract machine model, basic types, conversions, initializers, named constants, and binary representations.


5.1 The Abstract State Machine ​

C Deep Dive: The C standard does not describe a physical computer. Instead it defines an abstract state machine that specifies what a conforming program must do. A real compiler's job is to produce code that behaves as if the abstract machine executed the program.

The abstract machine has:

  • Objects — regions of storage that hold values (variables, allocated memory).
  • Values — the bit patterns stored in objects, interpreted according to their type.
  • Side effects — changes to the state of the machine (writing to a variable, calling an I/O function).
  • Sequence points — moments when all preceding side effects are guaranteed complete.

When you write int x = 42;, the abstract machine:

  1. Allocates storage for an object named x.
  2. Determines that its type is int.
  3. Stores the value 42 in that object.

Auto simplifies this model by removing undefined behavior. If an Auto program compiles, it has well-defined semantics. The trade-off is that Auto hides certain machine-level details that C exposes (such as raw pointer arithmetic and exact object layout).

Takeaway: C's abstract machine is a contract between you and the compiler. Stay within the contract and your code is portable and predictable. Violate it (e.g., via undefined behavior) and the compiler is free to do anything.


5.2 Basic Types ​

C has a small but nuanced set of fundamental types. Auto maps them to a cleaner subset:

C typeAuto typeSize (typical)Notes
charchar1 byteCharacter or small integer
signed chari81 byteExplicitly signed 8-bit
unsigned charu81 byteUnsigned 8-bit
shorti162 bytesShort integer
intint4 bytesDefault integer
longi644 or 8 bytesPlatform-dependent
long longi648 bytesAt least 64-bit
floatfloat4 bytesSingle-precision IEEE 754
doublefloat8 bytesDouble-precision; Auto uses float for both
_Boolbool1 byteC99 boolean; Auto has bool
size_tusize4 or 8 bytesUnsigned, sizeof result

Key differences:

  • C's double is distinct from float. Auto unifies them as float and lets the compiler choose the precision.
  • C has signed/unsigned variants for every integer type. Auto defaults to signed and provides explicit u8, u16, u32, u64 for unsigned needs.
  • C's char may be signed or unsigned depending on the platform. Auto treats char as a distinct type for character data only.

Released under the MIT License.