Search Apps Documentation Source Content File Folder Download Copy Actions Download State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

Brainfuck, on chain, a slice at a time

Demo of p/moul/x/vm/bf (the machine) and p/moul/x/vm/vmkit (the host ABI, the fuel meter, the instance store). This realm holds no logic of its own.

A program here does not run to completion. It runs until its fuel slice is spent, then pauses: the realm keeps the snapshot and the next caller pays for the next slice. Realm code cannot pause itself, and a guest can.

Samples

Hello World: 385 guest ops, five tape cells. Finishes in one slice.

++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.

Upload Hello World

Echo the input: Reads through Host.Input, which is what the naive interpreter could not do at all: it panicked on ,.

,[.,]

Upload Echo the input

Heavy loop: About 111k guest ops. Give it 20000 fuel and it takes six slices, which is the point.

++++++++++[->++++++++++[->++++++++++[-]<]<]

Upload Heavy loop

Instances

id status fuel used slices output
0000001 halted 32 1 Hello World

Limits

limit value
instances 64
source bytes 65536
input bytes 1024
output bytes 4096
fuel per slice 5000000
tape cells 30000