The Egg language spec
Egg core language specification (v2)
This is the complete definition of the v2 core: the v1 language plus
integer types of every width (section 7), modules (section 16), the io,
args, fs, net, thread and alloc capabilities (section 17), raw pointers behind allow unsafe
(section 18), function values (section 19), extern fn (section 20), and
owned buffers with defer (section 21).
It is written to be loaded into a model’s context in one piece, together
with grammar.ebnf (syntax) and diagnostics.md (error codes).
eggc spec prints all three.
Every ```egg block in this file is compiled and run by test/run.rb, so the
examples cannot drift from the compiler. A block’s // expect: lines are its
required output; // error: CODE means it must fail with that code;
// fails: Name means main must return error.Name.
Chapters
- Programs
- Lexical structure
- Types
- Declarations and names
- Functions
- Statements
- Expressions
- Strings
- Structs and methods
- Enums, unions and switch
- Arrays and slices
- inout parameters
- Errors
- Generics: comptime
- Builtins
- Modules
- Capabilities
- Pointers and allow unsafe
- Function values
- extern fn
- Buffers, ownership and defer
- Not yet
- A complete program
- Error codes