Type Articles: A, AN

Type articles are small keywords that improve readability in type declarations and expressions. They are syntactically optional but recommended for clarity.

Keywords

  • A - Singular article for types
  • AN - Singular article before vowel sounds

A / AN

Used in type annotations to improve readability.

Syntax

GIVEN name IS A Type
GIVEN name IS AN Type
ASSUME name IS A Type

Examples

Example file:

-- Type articles: A, AN, THE

-- Using A with Types

-- A before consonant sounds
ASSUME age IS A NUMBER
ASSUME name IS A STRING
ASSUME employed IS A BOOLEAN

-- A with function parameters
GIVEN x IS A NUMBER
double x MEANS x TIMES 2

#EVAL double 21

-- Using AN with Types

-- AN before vowel sounds (for readability)
DECLARE Account HAS
  balance IS A NUMBER
  holder IS A STRING

ASSUME myAccount IS AN Account

-- Both A and AN are syntactically valid
-- AN just reads better before vowels
GIVEN acc IS AN Account
getBalance acc MEANS acc's balance

-- Using THE for Field Access

DECLARE Person HAS
  personName IS A STRING
  personAge IS A NUMBER

DECIDE john IS Person WITH
  personName IS "John"
  personAge IS 30

-- Field access using genitive
DECIDE johnsName IS john's personName
DECIDE johnsAge IS john's personAge

#EVAL johnsName
#EVAL johnsAge

-- Comparing THE...OF vs Genitive

-- Genitive syntax for field access
DECIDE nameViaGenitive IS john's personName

#EVAL nameViaGenitive

-- Articles in Legal-Style Text

DECLARE Contract HAS
  effectiveDate IS A NUMBER
  amount IS A NUMBER

ASSUME agreement IS A Contract

-- Field access via genitive
DECIDE contractDate IS agreement's effectiveDate
DECIDE contractAmount IS agreement's amount
-- "A" before consonant sounds
ASSUME age IS A NUMBER
ASSUME name IS A STRING
GIVEN x IS A NUMBER

-- "AN" before vowel sounds
ASSUME account IS AN Account
GIVEN obj IS AN Object

Rules

  • Use A before consonant sounds: A NUMBER, A STRING, A BOOLEAN
  • Use AN before vowel sounds: AN Account, AN Integer
  • Both are syntactically equivalent — the distinction is for readability only

Note

Field access in L4 uses the genitive ('s) syntax:

DECLARE Person HAS
  name IS A STRING
  age IS A NUMBER

ASSUME john IS A Person

-- Access fields with genitive
DECIDE johnsName IS john's name
DECIDE johnsAge IS john's age

See

-- Example: Genitive ('s) for field access
-- Demonstrates possessive syntax for record fields

DECLARE Person
  HAS `full name` IS A STRING
      age         IS A NUMBER

DECIDE `the applicant` IS Person WITH
  `full name` IS "John Doe"
  age         IS 30

-- Using genitive (reads like English)
DECIDE `applicant age using genitive` IS `the applicant`'s age

-- Equivalent to using THE ... OF
DECIDE `applicant age using THE OF` IS age OF `the applicant`

#EVAL `applicant age using genitive`
#EVAL `applicant age using THE OF`

for details.

  • IS - Type assertions
  • DECLARE - Type declarations
  • GIVEN - Function parameters

See Also