From 60173e500af491133e1483f6be50e0835252ae94 Mon Sep 17 00:00:00 2001 From: Luis <42945842+ldiaz94@users.noreply.github.com> Date: Mon, 12 Oct 2026 14:08:12 +0100 Subject: [PATCH] Report 2026-10.17: COPY COPY(d, s) copies the elements of s to the start of d as one block, right when they overlap, checked against LEN(d). The library copied a byte at a time, rat's Buf most of all. By the owner's word. --- diff --git a/doc/raz.md b/doc/raz.md index ceebf97..97e6f5b 100644 --- a/doc/raz.md +++ b/doc/raz.md @@ -9,7 +9,7 @@ This report defines the language. It is short on purpose. Whatever it doesn't allow, raz doesn't have. -This is version 2026-10.16 of the report; section 12 says what each +This is version 2026-10.17 of the report; section 12 says what each version changed. 2026-10.11 and 2026-10.12 are a thaw the owner chose, for a language anyone can build again. They break programs written for 2026-10.10 and before: for 2026-10.9, say, the report of compiler @@ -768,6 +768,7 @@ | `LEN(a)` | the number of elements of an array or a string constant (an untyped constant) or of a slice (an `INT`) | | `NEW(p, a)` | sets `p: ^T` to a fresh, zeroed `T` from the allocator `a: ^Mem.Allocator`, or to `nil` if `a` has no room | | `MSG(e)` | the message of the error `e`, a `[]U8` | +| `COPY(d, s)` | copies the elements of `s` to the start of `d`, both arrays or slices of one type `T`; `LEN(s)` must be at most `LEN(d)` | | `SYSCALL(n, x1, ..., x6)` | Linux system call `n` with up to six arguments, each a pointer or an integer no wider than `INT`; the raw result, an `INT` (a negative number is `-errno`) | | `INC(v)`, `INC(v, k)` | adds 1, or `k`, to the integer variable `v`; it wraps, like `+` | | `DEC(v)`, `DEC(v, k)` | subtracts 1, or `k`, from `v` | @@ -787,6 +788,12 @@ `Mem.Allocator` (section 11) is the one type of the library the language names. +`COPY` is a statement, as `INC` is. It copies the bytes of `LEN(s)` +elements as one block, as an assignment of an array does, and is right +when `d` and `s` overlap, as in `COPY(a[1..n], a[0..n - 1])`. It is +checked as a slice is: past `LEN(d)`, it stops the program, unless the +module says `check off;`. + `INC` and `DEC` evaluate `v` once, so `INC(a[f(i)])` calls `f` once. They read `v` and then write it: two accesses, even through a `^VOLATILE` pointer, and not atomic; `XADD` is the atomic one. @@ -1916,6 +1923,8 @@ - **2026-10.16.** Record constants, and array and record constants of records, strings, procedures and more (section 4); `Str` gains `copy` (section 11). +- **2026-10.17.** `COPY` copies the elements of one array or slice to + another as a block (section 6.8). ## Appendix A. What an implementation chooses