diff options
| author | 2026-10-15 15:00:36 +0330 | |
|---|---|---|
| committer | 2026-10-15 15:00:36 +0330 | |
| commit | a5a5029a80a14be46c244b5bcca63e5e2cd9026f (patch) | |
| tree | 9ba84a7d2c5c0f8bdbba65eb9df57b6129c132e7 /docs/SPEC.md | |
| parent | TODO: implicit namespace at the top (diff) | |
std.Io.print/println take any mix of printable arguments (compiler expands per type); docs, conformance
Diffstat (limited to 'docs/SPEC.md')
| -rw-r--r-- | docs/SPEC.md | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/docs/SPEC.md b/docs/SPEC.md index b2aa5ea..266a1af 100644 --- a/docs/SPEC.md +++ b/docs/SPEC.md @@ -469,6 +469,8 @@ pn((int)(p + 1) - (int)p); // 1: p + 1 moves one word 3.11.6 `heap(e)` copies the value of `e` into a fresh owned heap block sized to it and returns a pointer to the block (a fresh object, 6.1): one word for a scalar or pointer (`heap(10)` is an `int*`), the characters and the terminating 0 for a `char*` word string (`heap("hi")` is a `char*`), and `sizeof(T)` words for a struct or array value (`heap(v)` with `v` a `foo` is a `foo*`). pointer fields of a copied struct are copied as plain words. a struct whose body declares `drop` gives the block its type drop (6.15). `heap` is found only when no variable or function of that name is in scope. +3.11.7 `std.Io.print(args)` and `std.Io.println(args)` take any number of arguments, including none. each argument is evaluated left to right and written by the writer for its type: a byte string (`bstr`) by `put_bs`, a float by `put_f`, a `char*` or `char[]` by `put_s`, anything else by `put_n`. a fresh owned string argument is written and then freed; another fresh object is error: a new object can't be printed; bind it to a name first. `println` then writes a line break. the call's value is 0. these two are the only calls with a variable number of arguments. + ### 3.12 `sizeof` and `typeof` 3.12.1 `sizeof(T)` and `sizeof(e)` give the size in words. the expression form is compiled but never run: `int i = 0; int n = sizeof(i++);` leaves `i` 0 and `n` 1. a `u8[100]` is 13 words, a struct of four `u8` fields is 1. |
