raz / commit 60173e50

commit
60173e500af491133e1483f6be50e0835252ae94
author
Luis <42945842+ldiaz94@users.noreply.github.com>
date
parent
46597e23
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.

patch · log

1 file changed, +10 -1

doc/raz.md (history) modified +10 -1

@@ -9,7 +9,7 @@
99 This report defines the language. It is short on purpose. Whatever it
1010 doesn't allow, raz doesn't have.
1111
12-This is version 2026-10.16 of the report; section 12 says what each
12+This is version 2026-10.17 of the report; section 12 says what each
1313 version changed. 2026-10.11 and 2026-10.12 are a thaw the owner chose,
1414 for a language anyone can build again. They break programs written
1515 for 2026-10.10 and before: for 2026-10.9, say, the report of compiler
@@ -768,6 +768,7 @@
768768 | `LEN(a)` | the number of elements of an array or a string constant (an untyped constant) or of a slice (an `INT`) |
769769 | `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 |
770770 | `MSG(e)` | the message of the error `e`, a `[]U8` |
771+| `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)` |
771772 | `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`) |
772773 | `INC(v)`, `INC(v, k)` | adds 1, or `k`, to the integer variable `v`; it wraps, like `+` |
773774 | `DEC(v)`, `DEC(v, k)` | subtracts 1, or `k`, from `v` |
@@ -787,6 +788,12 @@
787788 `Mem.Allocator` (section 11) is the one type of the library the
788789 language names.
789790
791+`COPY` is a statement, as `INC` is. It copies the bytes of `LEN(s)`
792+elements as one block, as an assignment of an array does, and is right
793+when `d` and `s` overlap, as in `COPY(a[1..n], a[0..n - 1])`. It is
794+checked as a slice is: past `LEN(d)`, it stops the program, unless the
795+module says `check off;`.
796+
790797 `INC` and `DEC` evaluate `v` once, so `INC(a[f(i)])` calls `f` once. They
791798 read `v` and then write it: two accesses, even through a `^VOLATILE`
792799 pointer, and not atomic; `XADD` is the atomic one.
@@ -1916,6 +1923,8 @@
19161923 - **2026-10.16.** Record constants, and array and record constants of
19171924 records, strings, procedures and more (section 4); `Str` gains
19181925 `copy` (section 11).
1926+- **2026-10.17.** `COPY` copies the elements of one array or slice to
1927+ another as a block (section 6.8).
19191928
19201929 ## Appendix A. What an implementation chooses
19211930