Raven language reference
Raven is an expression-oriented language for .NET. It combines concise functions and immutable data with classes, pattern matching, async programming, and direct access to the .NET ecosystem.
import System.*
record Temperature(Celsius: double)
func describe(value: Temperature) -> string {
value.Celsius match {
..<0 => "freezing"
0..<20 => "cold"
20..<30 => "comfortable"
_ => "hot"
}
}
let reading = Temperature(21.5)
Console.WriteLine(describe(reading))
This reference explains Raven by feature: what a construct is for, how to use it, and the rules that matter when code becomes more involved. It serves both as developer documentation and as Raven's working language specification.
The reference is precise where a distinction affects normal programs, .NET interoperability, or compiler diagnostics. It does not attempt to enumerate every compiler implementation detail or every possible invalid program.
Where to start
If you are new to Raven, begin with Values, expressions, and
statements,
Functions, and Unions.
Together
they introduce Raven's expression-oriented style, callable values, records,
unions, and the unit value.
If you already use C# or another .NET language, start with the Type system, Classes, structs, and interfaces, and .NET implementation notes. These pages show where Raven follows the CLR model and where its source-language conventions differ.
For a formal view of the syntax, see the non-normative EBNF grammar. Contextual and semantic rules remain in the feature articles.
Language fundamentals
Learn how Raven source is written and organized, how values and statements behave, and how an executable program starts.
- Lexical structure
- Values, expressions, and statements
- Namespaces, imports, and aliases
- Top-level code and entry points
- Grammar
Types
Explore Raven's built-in and .NET types, nullability, tuples, function types, unions, enums, and delegates. Unions remain a distinct feature because their closed alternatives, payloads, and exhaustiveness rules form a complete data-modeling construct rather than merely another annotation syntax.
Expressions
Expressions produce values. These articles cover inference, literals, calls, collections, tuples, pipelines, construction, and operators.
- Expressions and type inference
- Literals and fundamental expressions
- Collection expressions
- Calls
- Pipe expressions
- Object creation and copying
- Operators
Declarations and members
Define local values, reusable functions, and object-oriented types. These pages also cover generic constraints, overloads, properties, events, inheritance, and extension members.
- Local declarations
- Functions
- Async functions
- Classes, structs, and interfaces
- Type declarations and initialization
- Properties and events
- Inheritance and partial types
- Parameters, overloading, and operators
- Interfaces
- Extension members
Pattern matching
Pattern matching tests the shape and contents of a value while optionally binding its parts. Raven supports constants, ranges, types, sequences, properties, dictionaries, union cases, and nested combinations of patterns.
- Pattern matching
- Match forms
- Fundamental patterns
- Sequence and property patterns
- Deconstruction, member, and union patterns
- Dictionary patterns
- Match exhaustiveness
Control flow and errors
Branch, iterate, return, yield, jump, synchronize, and represent failure either as an exception or as an explicit carrier value.
- Control flow
- Conditionals and loops
- Statements
- Return and yield
- Jumps and labels
- Exceptions and structured handling
- Error propagation and carrier types
Metaprogramming
Raven macros transform syntax at compile time and can provide domain-specific language forms while remaining integrated with the compiler.
Systems programming and .NET interoperability
Use spans, stack allocation, managed references, pointers, unsafe code, and external declarations when working close to memory or a native boundary. The implementation notes describe how Raven concepts are represented on .NET.