cli: bootstrap verified std bytes and math with source imports
This commit is contained in:
52 files changed
+1000
-22
No files matched your search
@@ -316,3 +316,26 @@ scope s { // every task spawned in s must
|
||||
| E2111 | graph content not plain data | store only integers, booleans, enums, structs/arrays of them and `iref`s in a graph |
|
||||
| T0010 | `iref` of another graph | use a handle with the graph it came from |
|
||||
| T0001–T0009 | runtime trap | see `kind` and `source_location` |
|
||||
|
||||
## 10. Standard library
|
||||
|
||||
Import a bundled module after the module header; call its functions by their full path. `std.bytes` and `std.math` are safe source, declare `effects []` and allocate no heap. No grants are needed. Read `/docs/library/std.md` for the API.
|
||||
|
||||
```aji
|
||||
module demo.standard
|
||||
import std.bytes;
|
||||
import std.math;
|
||||
|
||||
fn main() -> u64
|
||||
effects []
|
||||
{
|
||||
var data: [u8; 4] = zero;
|
||||
std.bytes.fill(mut data, 65);
|
||||
assert(std.bytes.equal(ref data, b"AAAA"));
|
||||
let index = std.bytes.find(ref data, 65);
|
||||
if index < data.len { assert(data[index] == 65); }
|
||||
return std.math.clamp_u64(42, 0, 100);
|
||||
}
|
||||
```
|
||||
|
||||
`find` returns the searched slice's length when absent; check before indexing. `clamp_u64` traps `T0002` for an inverted range. Missing import/module/member: `E7002`; duplicate import: `E7006`; wrong arguments: `E7005`. There are no aliases or user generics in this increment.
|
||||
Reference in new issue
Block a user