authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-09-03 12:18:12-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-09-03 12:18:12-04:00
log3f273479f8f38fb408181b2ae2fff1acf4278ba1
treee4a469852c929fab205304070ba4d1ce77395663
parent2a9329c9988430cfa11a8bb4b02da0dce8749028
signaturelock-open Commit is signed but in an unrecognized format.

clarify const variables in docs

closes #1200

1 files changed, 4 insertions(+), 3 deletions(-)

doc/langref.html.in+4-3
...@@ -566,7 +566,7 @@ const c_string_literal =...@@ -566,7 +566,7 @@ const c_string_literal =
566 {#header_close#}566 {#header_close#}
567 {#header_close#}567 {#header_close#}
568 {#header_open|Assignment#}568 {#header_open|Assignment#}
569 <p>Use <code>const</code> to assign a value to an identifier:</p>569 <p>Use the <code>const</code> keyword to assign a value to an identifier:</p>
570 {#code_begin|test_err|cannot assign to constant#}570 {#code_begin|test_err|cannot assign to constant#}
571const x = 1234;571const x = 1234;
572572
...@@ -582,7 +582,8 @@ test "assignment" {...@@ -582,7 +582,8 @@ test "assignment" {
582 foo();582 foo();
583}583}
584 {#code_end#}584 {#code_end#}
585 <p>If you need a variable that you can modify, use <code>var</code>:</p>585 <p><code>const</code> applies to all of the bytes that the identifier immediately addresses. {#link|Pointers#} have their own const-ness.</p>
586 <p>If you need a variable that you can modify, use the <code>var</code> keyword:</p>
586 {#code_begin|test#}587 {#code_begin|test#}
587const assert = @import("std").debug.assert;588const assert = @import("std").debug.assert;
588589
...@@ -1918,7 +1919,7 @@ test "linked list" {...@@ -1918,7 +1919,7 @@ test "linked list" {
1918 assert(list2.first.?.data == 1234);1919 assert(list2.first.?.data == 1234);
1919}1920}
1920 {#code_end#}1921 {#code_end#}
1921 {#header_open|struct naming#}1922 {#header_open|struct Naming#}
1922 <p>Since all structs are anonymous, Zig infers the type name based on a few rules.</p>1923 <p>Since all structs are anonymous, Zig infers the type name based on a few rules.</p>
1923 <ul>1924 <ul>
1924 <li>If the struct is in the initialization expression of a variable, it gets named after1925 <li>If the struct is in the initialization expression of a variable, it gets named after