Values and types
Lesson from the WasmPascal in-browser Learn Pascal tutorial. Source: webpascal/index.html.
Pascal is a typed language: every variable and function result has a type, declared ahead of use. wasmpascal's types are:
- Integers:
Integer/LongInt(32-bit signed),Cardinal/LongWord(unsigned), plusShortInt(8-bit),SmallInt/Word(16-bit),Byte(unsigned 8-bit). - Floats:
Real/Double(64-bit),Single(32-bit). - Booleans:
Boolean,true/false. - Characters:
Char(one byte). - Enumerations:
type Color = (Red, Green, Blue)gives named values with ordinals 0, 1, 2 — usable incase, array bounds, andforcounters. Named subranges (type Index = 1..10) bound arrays and variables the same way. - Structured: records, static arrays (including multi-dim
array[1..3, 1..4] of Twitha[i, j]indexing), pointers, and strings (including fixedString[n]) — their own lessons below.
Floats and integers mix in expressions: integer arguments to math builtins are promoted to floats automatically.