authorgravatar for manlio.perillo@gmail.comManlio Perillo <manlio.perillo@gmail.com> 2022-12-09 12:02:27+01:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2022-12-09 18:24:40+02:00
log65f35a76f954c30717f641fde341771085abd06e
tree489a4f781e10606b69ad900a7f13eba961464a91
parent505a21bcc5e06c156f33551e8abea90db438f41d

langref: consistently use comptime-known and runtime-known


1 files changed, 8 insertions(+), 8 deletions(-)

doc/langref.html.in+8-8
......@@ -2511,7 +2511,7 @@ test "null terminated array" {
25112511 and vectors. Zig provides the {#link|@splat#} builtin to easily convert from scalars
25122512 to vectors, and it supports {#link|@reduce#} and array indexing syntax to convert
25132513 from vectors to scalars. Vectors also support assignment to and from fixed-length
2514 arrays with comptime known length.
2514 arrays with comptime-known length.
25152515 </p>
25162516 <p>
25172517 For rearranging elements within and between vectors, Zig provides the {#link|@shuffle#} and {#link|@select#} functions.
......@@ -2557,7 +2557,7 @@ test "Conversion between vectors, arrays, and slices" {
25572557 var offset: u32 = 1;
25582558 // To extract a comptime-known length from a runtime-known offset,
25592559 // first extract a new slice from the starting offset, then an array of
2560 // comptime known length
2560 // comptime-known length
25612561 const vec3: @Vector(2, f32) = slice[offset..][0..2].*;
25622562 try expectEqual(slice[offset], vec2[0]);
25632563 try expectEqual(slice[offset + 1], vec2[1]);
......@@ -3013,7 +3013,7 @@ test "slice pointer" {
30133013
30143014 {#header_open|Sentinel-Terminated Slices#}
30153015 <p>
3016 The syntax {#syntax#}[:x]T{#endsyntax#} is a slice which has a runtime known length
3016 The syntax {#syntax#}[:x]T{#endsyntax#} is a slice which has a runtime-known length
30173017 and also guarantees a sentinel value at the element indexed by the length. The type does not
30183018 guarantee that there are no sentinel elements before that. Sentinel-terminated slices allow element
30193019 access to the {#syntax#}len{#endsyntax#} index.
......@@ -3233,7 +3233,7 @@ test "default struct initialization fields" {
32333233 .b = 5,
32343234 };
32353235 if (x.a + x.b != 1239) {
3236 @compileError("it's even comptime known!");
3236 @compileError("it's even comptime-known!");
32373237 }
32383238}
32393239 {#code_end#}
......@@ -4257,7 +4257,7 @@ fn isFieldOptional(comptime T: type, field_index: usize) !bool {
42574257 const fields = @typeInfo(T).Struct.fields;
42584258 return switch (field_index) {
42594259 // This prong is analyzed `fields.len - 1` times with `idx` being an
4260 // unique comptime known value each time.
4260 // unique comptime-known value each time.
42614261 inline 0...fields.len - 1 => |idx| @typeInfo(fields[idx].field_type) == .Optional,
42624262 else => return error.IndexOutOfBounds,
42634263 };
......@@ -4352,8 +4352,8 @@ const U = union(enum) {
43524352
43534353fn getNum(u: U) u32 {
43544354 switch (u) {
4355 // Here `num` is a runtime known value that is either
4356 // `u.a` or `u.b` and `tag` is `u`'s comptime known tag value.
4355 // Here `num` is a runtime-known value that is either
4356 // `u.a` or `u.b` and `tag` is `u`'s comptime-known tag value.
43574357 inline else => |num, tag| {
43584358 if (tag == .b) {
43594359 return @floatToInt(u32, num);
......@@ -6399,7 +6399,7 @@ test "coercion to error unions" {
63996399const std = @import("std");
64006400const expect = std.testing.expect;
64016401
6402test "coercing large integer type to smaller one when value is comptime known to fit" {
6402test "coercing large integer type to smaller one when value is comptime-known to fit" {
64036403 const x: u64 = 255;
64046404 const y: u8 = x;
64056405 try expect(y == 255);