FOL Language Specification
FOL is intended as a general-purpose and systems-oriented programming language with a compact declaration syntax, a rich type system, and a strong preference for explicit structure.
This book is the specification draft for the language.
Core Shape
Much of the surface syntax follows the same high-level shape:
declaration[options] name: type = { body }
That pattern appears across:
- bindings
- routines
- type declarations
- module-like declarations
- standards
Main Declaration Families
The main declaration families are:
use // import declarations
def // named definitions such as modules, blocks, and tests
seg // segment/module-like declarations
var // bindings; use var[imu] for immutability
con // constants
lab // labels and label-like bindings
fun // functions
pro // procedures
log // logical routines
typ // named types
ali // aliases
std // standards: protocol, blueprint, extension
Expression And Control Surface
FOL combines block-oriented control flow with expression forms:
if (condition) { ... }
when (value) { ... }
while (condition) { ... }
loop (condition) { ... }
for (binder in iterable) { ... }
each (binder in iterable) { ... }
Expressions include:
- literals
- calls and method calls
- ranges and container literals
- access forms
- pipes
- rolling expressions
- anonymous routines and lambdas
How To Use This Book
The book is organized from language foundation to higher-level facilities:
- lexical structure
- statements and expressions
- metaprogramming
- types
- declarations and items
- modules and source layout
- errors
- sugar and convenience forms
- conversions
- memory model
- concurrency
Read Notation And Conventions before using chapter examples as a normative reference.
For the current user-facing tool workflow, read Frontend Workflow.
Example
This example uses the hosted std.io surface. Its artifact therefore selects
fol_model = "memo", and its build.fol explicitly declares:
build.add_dep({ alias = "std", source = "internal", target = "standard" });
The dependency is required by the source-level hosted calls, not because
main is executable.
use std: pkg = {"std"};
var[hid] prefix: str = "arith";
fun[] main(): int = {
std::io::echo_str(prefix);
std::io::echo_int(add(3, 5));
return 0;
}
fun[exp] add(a, b: int): int = {
return a + b;
}