ReferenceControlArcReferenceTypes

Types

Arc type system reference for primitives, channels, series, units, and type casting

Primitive Types

Integer Types

TypeSizeRange
i88-bit signed-128 to 127
i1616-bit signed-32,768 to 32,767
i3232-bit signed-2,147,483,648 to 2,147,483,647
i6464-bit signed-9.2×1018 to 9.2×1018
u88-bit unsigned0 to 255
u1616-bit unsigned0 to 65,535
u3232-bit unsigned0 to 4,294,967,295
u6464-bit unsigned0 to 1.8×1019

Floating Point Types

TypeSizePrecision
f3232-bit~7 decimal digits
f6464-bit~15 decimal digits

String Type

TypeDescription
strImmutable UTF-8 string

Type Defaults

When you write a literal without an explicit type, Arc infers a default:

LiteralDefault Type
42i64
3.14f64
"text"str
[1, 2, 3]series i64
[1.0, 2.0]series f64

Boolean Semantics

Arc uses u8 for boolean values. There is no separate boolean type.

ValueMeaning
0false
non-zerotrue

Logical operators normalize results to 0 or 1:

result := 2 and 3 // 1 (both truthy)
result := 5 or 0 // 1 (short-circuits)
negated := not 5 // 0

Comparison operators return u8:

is_high := pressure > 500 // 0 or 1

Channel Types

Channels connect Arc to Synnax telemetry data. Declare channel types with chan:

chan f64 // channel of float64
chan i32 // channel of int32

Channel names reference channels that exist in your Synnax cluster:

value := ox_pt_1 // read from channel
ox_pt_cmd = value // write to channel

Reading from a channel that has no data returns the zero value for that type.

Series Types

Series are homogeneous arrays. Declare series types with series:

series f64 // array of float64
series i32 // array of int32

Series Literals

data := [1.0, 2.0, 3.0] // series f64
empty series f64 := [] // empty series (type required)

Series Operations

length := len(data) // i64: number of elements
first := data[0] // indexing (0-based)
subset := data[1: 3] // slicing [start:end)

Element-wise Operations

Arithmetic and comparison operators work element-wise on series:

data := [1.0, 2.0, 3.0]
// Scalar operations
scaled := data * 2.0 // [2.0, 4.0, 6.0]
offset := data + 10.0 // [11.0, 12.0, 13.0]
// Series-to-series (must be equal length)
sum := data + [4.0, 5.0, 6.0] // [5.0, 7.0, 9.0]
// Comparisons return series u8
mask := data > 2.0 // [0, 0, 1]

Out-of-bounds access causes a runtime error. Series-to-series operations require equal-length arrays.

Unit Annotations

Types can carry a single unit suffix for dimensional tracking. The suffix is one identifier drawn from the built-in registry (length, time, mass, pressure, frequency, voltage, current, temperature, angle, data, count):

distance f64 m := 50.0
duration i64 ns := 1000000000
pressure f64 psi := 14.7

Only single-identifier units are accepted in source syntax. Compound units like m/s or m^2 are not spelled directly in declarations. They arise implicitly from arithmetic (see below).

Dimensional Compatibility

The compiler enforces dimensional compatibility:

  • Addition/Subtraction: Operands must have compatible dimensions
  • Multiplication/Division: Always valid; the result’s dimensions combine
  • Exponentiation: A dimensioned base requires a literal integer exponent
distance f64 m := 10.0
time f64 s := 2.0
// Division produces a length/time quantity (a velocity)
speed := distance / time
// Exponentiation produces a length^2 quantity (an area)
area := distance ^ 2

The dimensions of speed and area are tracked by the compiler and checked against any further use, but they are not spelled in source code.

Type Casting

Explicit casting converts between numeric types:

x i32 := 42
y f64 := f64(x) // int to float

a f64 := 3.7
b i64 := i64(a) // truncates to 3

Casting Rules

ConversionBehavior
Widening (e.g., i16 to i64)Safe, sign/zero extend
Narrowing (e.g., i64 to i8)Truncates
Signed to unsignedSaturates at bounds
Float to integerTruncates toward zero, saturates on overflow
Integer overflowTwo’s-complement wrapping

Arc requires explicit casts for mixed-type arithmetic. No implicit type promotion.

// Wrong: type error
x i32 := 42
y f64 := x + 1.0
// Right: explicit cast
x i32 := 42
y f64 := f64(x) + 1.0

Zero Values

All types have default zero values:

TypeZero Value
integers0
floats0.0
str"" (empty string)
series[] (empty series)
channelszero value of element type (on first read)

String Operations

Strings support the following operations:

msg := "Hello"
greeting := msg + " World" // concatenation
first := msg[0] // indexing (returns u8)
sub := msg[1: 4] // slicing
length := len(msg) // length in bytes
equal := msg == "Hello" // equality (returns u8: 1 or 0)
OperationSupported
+ (concatenation)Yes
==, != (equality)Yes
[] (indexing)Yes
[:] (slicing)Yes
len()Yes
<, >, <=, >=No