Qu

fifo

Builtin index · Collections & strings

result = fifo(capacity)

Input: capacity · Output: result

What it is

capacity is a number (positive integer, the buffer's fixed size, set once with no resize).

Overloads

One call shape — this function is not overloaded.

CodeInputOutputDescription
result = fifo(capacity)
capacity numbernot documented yet
result —
Returns a fifo handle: a new, empty ring buffer.

Examples

From the documentation, and run by the build -- the output and the figure below are what the engine actually produced. Simplest first.

f = fifo(3)
f.push(1)
f.push(2)
f.push(3)
f.push(4)          # evicts 1 -- buffer is now [2, 3, 4]

print(peek(f))       # 2 -- oldest element, still there

print(f.pop())      # 2

print(len(f))        # 2

output
2
2
2

from collections-strings

print("mm(10)={mm(10)}  cm(1)={cm(1)}  inch(1)={inch(1)}")   # e.g. figure_size(mm(180), mm(120))


f = fifo(2)
print("is_empty={is_empty(f)}")
push(f, 1)
push(f, 2)
print("is_full={is_full(f)}")   # at capacity -- the next push would evict the oldest

output
mm(10)=100  cm(1)=100  inch(1)=254
is_empty=true
is_full=true

from core-math

How it works

fifo(capacity) (§ data structures pass, 2026-09-01, Value::Fifo is a guarded arm further up this match (see its own comment there, next to queue()'s own unconditional "push"); every other fifo name has no competing meaning anywhere else, so this arm is unconditional.

From the note above this builtin in the interpreter, where the reasoning was written down as it was built.