aboutsummaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2019-01-29 21:47:26 -0500
committerAndrew Kelley <andrew@ziglang.org>2019-01-29 22:30:30 -0500
commit581edd643fb18a66c472f77e2f8cd3f4cea524a2 (patch)
treea03f6a3ade952729456b94584f21d4beb51a4802 /doc
parent9c328b42916d463465b134457c7f13b5c65da406 (diff)
downloadzig-581edd643fb18a66c472f77e2f8cd3f4cea524a2.tar.gz
zig-581edd643fb18a66c472f77e2f8cd3f4cea524a2.zip
backport copy elision changes
This commit contains everything from the copy-elision-2 branch that does not have to do with copy elision directly, but is generally useful for master branch. * All const values know their parents, when applicable, not just structs and unions. * Null pointers in const values are represented explicitly, rather than as a HardCodedAddr value of 0. * Rename "maybe" to "optional" in various code locations. * Separate DeclVarSrc and DeclVarGen * Separate PtrCastSrc and PtrCastGen * Separate CmpxchgSrc and CmpxchgGen * Represent optional error set as an integer, using the 0 value. In a const value, it uses nullptr. * Introduce type_has_one_possible_value and use it where applicable. * Fix debug builds not setting memory to 0xaa when storing undefined. * Separate the type of a variable from the const value of a variable. * Use copy_const_val where appropriate. * Rearrange structs to pack data more efficiently. * Move test/cases/* to test/behavior/* * Use `std.debug.assertOrPanic` in behavior tests instead of `std.debug.assert`. * Fix outdated slice syntax in docs.
Diffstat (limited to 'doc')
-rw-r--r--doc/langref.html.in13
1 files changed, 7 insertions, 6 deletions
diff --git a/doc/langref.html.in b/doc/langref.html.in
index 6e03d3ec6d..909c0f5817 100644
--- a/doc/langref.html.in
+++ b/doc/langref.html.in
@@ -4327,7 +4327,7 @@ fn gimmeTheBiggerInteger(a: u64, b: u64) u64 {
<p>
For example, if we were to introduce another function to the above snippet:
</p>
- {#code_begin|test_err|unable to evaluate constant expression#}
+ {#code_begin|test_err|values of type 'type' must be comptime known#}
fn max(comptime T: type, a: T, b: T) T {
return if (a > b) a else b;
}
@@ -5905,13 +5905,13 @@ fn add(a: i32, b: i32) i32 { return a + b; }
This function is a low level intrinsic with no safety mechanisms. Most code
should not use this function, instead using something like this:
</p>
- <pre>{#syntax#}for (source[0...byte_count]) |b, i| dest[i] = b;{#endsyntax#}</pre>
+ <pre>{#syntax#}for (source[0..byte_count]) |b, i| dest[i] = b;{#endsyntax#}</pre>
<p>
The optimizer is intelligent enough to turn the above snippet into a memcpy.
</p>
<p>There is also a standard library function for this:</p>
<pre>{#syntax#}const mem = @import("std").mem;
-mem.copy(u8, dest[0...byte_count], source[0...byte_count]);{#endsyntax#}</pre>
+mem.copy(u8, dest[0..byte_count], source[0..byte_count]);{#endsyntax#}</pre>
{#header_close#}
{#header_open|@memset#}
@@ -5923,7 +5923,7 @@ mem.copy(u8, dest[0...byte_count], source[0...byte_count]);{#endsyntax#}</pre>
This function is a low level intrinsic with no safety mechanisms. Most
code should not use this function, instead using something like this:
</p>
- <pre>{#syntax#}for (dest[0...byte_count]) |*b| b.* = c;{#endsyntax#}</pre>
+ <pre>{#syntax#}for (dest[0..byte_count]) |*b| b.* = c;{#endsyntax#}</pre>
<p>
The optimizer is intelligent enough to turn the above snippet into a memset.
</p>
@@ -6592,9 +6592,10 @@ pub const TypeInfo = union(TypeId) {
{#header_close#}
{#header_open|@typeName#}
- <pre>{#syntax#}@typeName(T: type) []u8{#endsyntax#}</pre>
+ <pre>{#syntax#}@typeName(T: type) [N]u8{#endsyntax#}</pre>
<p>
- This function returns the string representation of a type.
+ This function returns the string representation of a type, as
+ an array. It is equivalent to a string literal of the type name.
</p>
{#header_close#}