Spec chapters

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

  1. Programs
  2. Lexical structure
  3. Types
  4. Declarations and names
  5. Functions
  6. Statements
  7. Expressions
  8. Strings
  9. Structs and methods
  10. Enums, unions and switch
  11. Arrays and slices
  12. inout parameters
  13. Errors
  14. Generics: comptime
  15. Builtins
  16. Modules
  17. Capabilities
  18. Pointers and allow unsafe
  19. Function values
  20. extern fn
  21. Buffers, ownership and defer
  22. Not yet
  23. A complete program
  24. Error codes