Skip to main content

Types and values

Argon's types fall into scalars, collections, tuples, and layout types. Write types out in cell and function signatures: some can be inferred, but explicit signatures make call sites and error messages clearer.

Structs, enums, functions, and cells may take type parameters, written in angle brackets after the name: struct Pair<A, B>, fn last<T>(items: [T]) -> T. A type parameter stands for one type per use, which is inferred from the arguments, and a value of type T can only be stored, passed, and returned.

TypeExampleUsed for
Float12., -0.5Coordinates, distances, and linear expressions
Int12, -3Counts, indices, and discrete parameters
Booltrue, falseConditions and flags
String"met1"Layer names and text
Rectrect("met1")Rectangles, drawn or construction-only
Polygonpolygon("met1", 3)Polygons
Pathpath("met1", 2)Paths with a width
Pointshape.points[0]A polygon or path vertex
Instinst(child())A placed cell
[T][Float]A sequence of one type
(A, B)(3, 5,)A fixed-size tuple of mixed types
Option<T>Some(3), NoneA value that may be absent
AnyA value of any type
()()The unit value and type

Numeric literals

The decimal point is what makes a literal a float:

let count = 50; // Int
let distance = 50.; // Float

Geometry and constraints use Float. Counts and indices use Int.

Operators and casts

Arithmetic: +, -, *, /, and %. Comparison: ==, !=, <, <=, >, and >=.

Cast with as:

let offset = (index as Float) * pitch;

Sequences and tuples

Build a sequence with list or cons, index it with brackets, and walk it with head and tail.

let widths = list(80., 120., 160.);
let first = widths[0];
let pair = (first, 3,);

std::range makes an integer sequence for loops.