The Scaly Programming Language


Table of Contents
1 Introduction
Overview
Design Philosophy
Implementation Status
2 Lexical Structure
Overview
Whitespace and Line Breaks
Comments
Literals
Integer Literals
Floating-Point Literals
String Literals
Character Literals
Boolean Literals
Operators and Special Symbols
The Equals Sign
Identifiers
3 Type System
Overview
Intrinsic Types
Type Aliases
Backend Preludes
Literal Type Inference
References and Aliasing
Low-Level Pointers
Nullable Values
Parameter Passing
Implementation
Mutation via Procedures
Constructors
Implicit Constructors
Explicit Constructors
The this Prefix
Complete Initialization
Constructor Return
Constructed Value Lifetime
Page-Parameterized Constructors (init#)
Closures (Lambdas)
Capturing Variables
Closures Are Pure
Closure Lifetime
Implementation
Error Handling
The throws Clause
Single Error Type
The try/when Pattern
Error Propagation
Error Lifetime
Union Types
Memory Layout
Pattern Matching with choose
Option Type
Option Optimization
Generics
Monomorphization
Name Mangling
Lifetimes and Memory Regions
Stack vs Page Allocation
Lifetime Kinds
Local Lifetime ($)
Caller Lifetime (#)
Thrown Lifetime (!)
Reference Lifetime (^name)
By-Value Returns
Lifetime Inference
4 Grammar
5 Definitions
Overview
Definitions
Structure Definitions
Union Definitions
6 Expressions
Overview
Literals
Boolean Literals
Integer Literals
Hexadecimal Literals
Floating-Point Literals
String Literals
Character Literals
Operations
Prefix Functions
Operator Chains
Parentheses and Grouping
Identifier Shapes
Let Bindings
Comparison Operators
Equality
Relational Operators
Boolean Operators
Boolean Negation
Boolean And/Or
Bitwise Operators
Bit Shifts
If Expressions
Match Expressions
Choose Expressions
Choose on Variant Construction
Choose with Binding
Multiple When Clauses
Optional Types
Is Null Check
Optional Type Sugar
Generic Option Types
Variant Construction
Construct Variants
Variant Is Expression
A. Standard Library Reference
Types
define Sum(left: int, right: int)
define Difference(left: int, right: int)
define Product(left: int, right: int)
define Quotient(left: int, right: int)
Operators
operator +(left: int, right: int) returns Sum
operator -(left: int, right: int) returns Difference
operator *(left: int, right: int) returns Product
operator /(left: int, right: int) returns Quotient
operator div(left: int, right: int) returns int
operator mod(left: int, right: int) returns int
operator =(left: int, right: int) returns bool
operator <>(left: int, right: int) returns bool
operator <(left: int, right: int) returns bool
operator >(left: int, right: int) returns bool
operator <=(left: int, right: int) returns bool
operator >=(left: int, right: int) returns bool
Functions
function -(right: int) returns int
function +(right: int) returns int
function abs(x: int) returns int
List of Examples
3-1. LLVM Prelude (excerpt)
3-2. JavaScript Prelude (excerpt)