Polyscript is a Rust-like toy language with static typing, reference counting, and an LLVM AOT compiler.
The documentation comes in two parts. The guide introduces the language in order, and is meant to be read from beginning to end — each chapter uses only what the chapters before it have established. The reference holds the exhaustive tables, and is meant to be looked things up in.
- Syntax and Basics: Comments, primitive types, literals, operators, variables, casting, and
sizeof. - Control Flow: Blocks,
if-elseexpressions,forandwhileloops. - Functions: Declarations, parameters, divergence, function expressions and types, and closures.
- Structs and Enums: Building compound types, field visibility, discriminants, and type aliases.
- Implementations: Attaching methods, constants, and associated types to a type.
- Traits: Shared behavior, path qualifiers, operator overloading, and
Drop. - Generics: Type parameters, constraints, and monomorphization.
- Memory Model: Copy and heap types, reference counting, destruction, and raw memory.
- Modules: Code organization using
importandexport.
- A: Grammar: Every keyword, token, and syntactic production.
- B: Operators and Casts: The operator-to-trait mapping and the legal conversions.
- C: Standard Library: Intrinsics and the complete API of every standard library module.
- Compiler Internals: An explanation of the compiler's architecture and compilation pipeline.
After compiling the compiler into an executable ./polyscriptcc, running ./polyscriptcc --help will give further instructions as to how to compile a Polyscript program. The native standard library is provided here.