The Standard Library & CLI
Forty-eight builtins, four subcommands, eight flags, three faces. This is all of Sure; there is deliberately not more.
Anything
| Builtin | Does |
|---|---|
| print(x) | prints Int, Float, Bool, or String, with a newline |
| len(x) | length of a String (bytes), array, or map |
| str(x) | Int, Float, or Bool as a String |
Strings
| Builtin | Does |
|---|---|
| slice(s, start, end) | byte range, end exclusive, clamped |
| find(s, needle) | first index, or -1 |
| split(s, sep) | [String] of the pieces |
| join(parts, sep) | the pieces, reassembled |
| contains / starts_with / ends_with | Bool questions |
| trim(s) | without surrounding whitespace |
| upper(s) / lower(s) | ASCII case |
| replace(s, old, new) | all occurrences |
| byte_at(s, i) | one byte as Int, bounds-checked |
| chr(n) | one byte as String |
| to_int(s) / to_float(s) | parsed, or zero |
Numbers
| Builtin | Does |
|---|---|
| to_float(n) | Int, widened |
| trunc / round / floor / ceil | Float to Int, four opinions |
| sqrt(f) | the square root |
| abs(x) / min(a, b) / max(a, b) | Int or Float, matching |
Arrays
| Builtin | Does |
|---|---|
| push(xs, v) | appends |
| pop(xs) | removes and returns the last (aborts if empty) |
| sort(xs) | in place; [Int], [Float], or [String] |
Maps
| Builtin | Does |
|---|---|
| has(m, key) | Bool |
| delete(m, key) | removes, if present |
| keys(m) | [K], in the map's order, not yours |
Channels
| Builtin | Does |
|---|---|
| channel() / channel(cap) | a new channel, typed by its declaration |
| send(c, v) | delivers; waits for room, or for a receiver |
| recv(c) | waits for a value; aborts on closed-and-empty |
| close(c) | no more values are coming |
The world
| Builtin | Does |
|---|---|
| args() | [String]; index 0 is the program |
| getenv(name) | the variable, or "" |
| read_line() | one line of stdin, or "" at end |
| time_ms() | milliseconds since the epoch |
| read_file(path) | the bytes, or "" if it isn't there |
| write_file(path, data) | Bool, honestly earned |
| file_exists(path) | Bool |
| tcp_listen(port) | a listener, or -1 |
| tcp_accept(fd) | waits for a connection |
| tcp_recv(fd) | up to 64 KB, as a String |
| tcp_send(fd, data) | sends it all; returns bytes sent |
| tcp_close(fd) | done |
The CLI
| Command | Does |
|---|---|
| sure build file.sure [-o OUT] | compiles. prints 👍. |
| sure run file.sure | compiles and runs; prints only your program's output |
| sure expand file.sure | the post-macro source, plainly |
| sure blame file.sure f.x | where x was freed, and the reasoning |
| sure doctor | checks python, the C compiler, the key, the cache; compiles a test program; tells you you're fine |
| sure version | sure 0.3.1 (fearless-concurrency) |
| Flag | Does |
|---|---|
| --creativity FLOAT | memory-layout creativity; 0.7 is suitable for production |
| --fresh-eyes | re-runs inference; the first remediation |
| --prompt FILE | standing guidance for the compiler |
| --model NAME | the model |
| --api-key KEY | the memory-safety service key (default: SURE_API_KEY) |
| --emit-ir | writes the LLVM IR beside the output |
| --verbose | compile time and per-function confidence |
| --reassure | adds reassurance |
The three faces
| Face | Means |
|---|---|
| 👍 | everything is fine. this is the whole message. |
| 🫤 | an error. the indented line below it is precise. |
| 🤔 | a warning. look at the line. it knows what it did. |