From fdb79e4b87a2fda6f784e087893060b581be54e3 Mon Sep 17 00:00:00 2001 From: Luis <42945842+ldiaz94@users.noreply.github.com> Date: Fri, 16 Oct 2026 10:50:37 +0100 Subject: [PATCH] Report 2026-10.30: [] used as a slice is the empty slice A defect mended: 7.3 made returning [] an error, as an array literal, which the compiler never was. [] is the empty slice, ptr nil and len 0, and no hidden variable (6.5). --- diff --git a/doc/raz.md b/doc/raz.md index d4551c6..d28f11b 100644 --- a/doc/raz.md +++ b/doc/raz.md @@ -13,7 +13,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.29 of the report; section 11 says where each +This is version 2026-10.30 of the report; section 11 says where each version's changes are told. 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 @@ -32,7 +32,9 @@ array a call returns lives to the end of its statement, and a slice of it kept past that is undefined (sections 8 and 10). 2026-10.29 is a sixth thaw: an array constant typed `[]T` takes its length from its -literal (section 4); it breaks no program. +literal (section 4); it breaks no program. 2026-10.30 mends a defect: +`[]` used as a slice is the empty slice, which may be returned +(sections 6.5 and 7.3); it breaks no program. The language is frozen, softly, from this version on: it changes only to mend a defect, and its library grows only by what breaks no program @@ -776,7 +778,9 @@ A record literal names its fields, in any order, each at most once; the fields it leaves out are zero, so `{}` is the record with every field zero. An array literal used as a slice is a -hidden variable of the procedure, and lives as long as its call. +hidden variable of the procedure, and lives as long as its call; +the empty one, `[]`, is the empty slice, as a slice variable starts +(section 4), and no variable at all. ``` c := {ch: 'A', attr: 7}; @@ -1052,9 +1056,9 @@ A slice returned must not point into the procedure's own frame, which is gone once it returns. It is an error to return, as a slice, a local -array, a value parameter that is an array, an array literal, or an -array a call returns, or a slice of one, a field or an element of one -included: +array, a value parameter that is an array, an array literal other than +`[]`, or an array a call returns, or a slice of one, a field or an +element of one included: ``` proc short(h: Hex): []U8; (* Hex = [64]U8 *) diff --git a/doc/report-history.md b/doc/report-history.md index 186faac..5d68644 100644 --- a/doc/report-history.md +++ b/doc/report-history.md @@ -176,3 +176,7 @@ `dupAbove`, `group`, `fork`, `handle` and `came`, and `wait` on a group; `Map` gains `done`, `Str` gains `free`, and `Files` gains `load`, and tries again after EINTR (volume 2). +- **2026-10.30.** A defect mended: `[]` used as a slice is the empty + slice, `ptr` `nil` and `len` 0, and no hidden variable, so it may be + returned (sections 6.5 and 7.3); 7.3 had made returning it an error, + which the compiler never was. It breaks no program.