pub enum Expr<'a> {
Show 26 variants
Literal(Literal),
Identifier(Symbol),
BinaryOp {
op: BinaryOpKind,
left: &'a Expr<'a>,
right: &'a Expr<'a>,
},
Call {
function: Symbol,
args: Vec<&'a Expr<'a>>,
},
Index {
collection: &'a Expr<'a>,
index: &'a Expr<'a>,
},
Slice {
collection: &'a Expr<'a>,
start: &'a Expr<'a>,
end: &'a Expr<'a>,
},
Copy {
expr: &'a Expr<'a>,
},
Give {
value: &'a Expr<'a>,
},
Length {
collection: &'a Expr<'a>,
},
Contains {
collection: &'a Expr<'a>,
value: &'a Expr<'a>,
},
Union {
left: &'a Expr<'a>,
right: &'a Expr<'a>,
},
Intersection {
left: &'a Expr<'a>,
right: &'a Expr<'a>,
},
ManifestOf {
zone: &'a Expr<'a>,
},
ChunkAt {
index: &'a Expr<'a>,
zone: &'a Expr<'a>,
},
List(Vec<&'a Expr<'a>>),
Tuple(Vec<&'a Expr<'a>>),
Range {
start: &'a Expr<'a>,
end: &'a Expr<'a>,
},
FieldAccess {
object: &'a Expr<'a>,
field: Symbol,
},
New {
type_name: Symbol,
type_args: Vec<TypeExpr<'a>>,
init_fields: Vec<(Symbol, &'a Expr<'a>)>,
},
NewVariant {
enum_name: Symbol,
variant: Symbol,
fields: Vec<(Symbol, &'a Expr<'a>)>,
},
Escape {
language: Symbol,
code: Symbol,
},
OptionSome {
value: &'a Expr<'a>,
},
OptionNone,
WithCapacity {
value: &'a Expr<'a>,
capacity: &'a Expr<'a>,
},
Closure {
params: Vec<(Symbol, &'a TypeExpr<'a>)>,
body: ClosureBody<'a>,
return_type: Option<&'a TypeExpr<'a>>,
},
CallExpr {
callee: &'a Expr<'a>,
args: Vec<&'a Expr<'a>>,
},
}Expand description
Shared expression type for pure computations (LOGOS §15.0.0).
Expr is used by both LogicExpr (as terms) and Stmt (as values). These are pure computations without side effects.
Variants§
Literal(Literal)
Literal value: 42, “hello”, true, nothing
Identifier(Symbol)
Variable reference: x
BinaryOp
Binary operation: x plus y
Call
Function call as expression: f(x, y)
Index
Dynamic index access: items at i (1-indexed).
Slice
Dynamic slice access: items 1 through mid (1-indexed, inclusive).
Copy
Copy expression: copy of slice → slice.to_vec().
Give
Give expression: Give x → transfers ownership, no clone needed.
Used in function calls to explicitly move values.
Length
Length expression: length of items → items.len().
Contains
Set contains: set contains x or x in set
Union
Set union: a union b
Intersection
Set intersection: a intersection b
ManifestOf
Get manifest of a zone.
the manifest of Zone → FileSipper::from_zone(&zone).manifest()
ChunkAt
Get chunk at index from a zone.
the chunk at N in Zone → FileSipper::from_zone(&zone).get_chunk(N)
List(Vec<&'a Expr<'a>>)
List literal: [1, 2, 3]
Tuple(Vec<&'a Expr<'a>>)
Tuple literal: (1, “hello”, true)
Range
Range: 1 to 10 (inclusive)
FieldAccess
Field access: p's x or the x of p.
New
Constructor: a new Point or a new Point with x 10 and y 20.
Supports generics: a new Box of Int and nested types: a new Seq of (Seq of Int)
NewVariant
Enum variant constructor: a new Circle with radius 10.
Escape
Escape hatch expression: raw foreign code that produces a value.
Used in expression position: Let x: Int be Escape to Rust:
OptionSome
Option Some: some 30 → Some(30)
OptionNone
Option None: none → None
WithCapacity
Pre-allocation capacity hint wrapping an inner value expression.
"" with capacity 100 or a new Seq of Int with capacity n
Codegen uses with_capacity(); interpreter ignores the hint.
Closure
Closure expression: (params) -> body or (params) ->: block body.
Captures variables from the enclosing scope by value (snapshot/clone).
Fields
body: ClosureBody<'a>CallExpr
Call an expression that evaluates to a callable value.
f(x) where f is a variable holding a closure, not a named function.