aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTuncer Ayaz <[email protected]>2010-04-20 20:44:45 +0200
committerTuncer Ayaz <[email protected]>2010-04-20 20:46:49 +0200
commit45c380d1b77198449fb8e3beadb39dc8f77abb72 (patch)
tree3e3ccacf78bf209a0797196084cab0e599233858
parent3829e5facc98f1c1d3113b648c0b9fa7362cad32 (diff)
downloadotp-45c380d1b77198449fb8e3beadb39dc8f77abb72.tar.gz
otp-45c380d1b77198449fb8e3beadb39dc8f77abb72.tar.bz2
otp-45c380d1b77198449fb8e3beadb39dc8f77abb72.zip
Document R14 paren-less record access/update
Add a section to the reference manual describing the R14 change to not require parentheses when accessing or updating fields in nested records. Signed-off-by: Tuncer Ayaz <[email protected]>
-rw-r--r--system/doc/reference_manual/records.xml23
1 files changed, 23 insertions, 0 deletions
diff --git a/system/doc/reference_manual/records.xml b/system/doc/reference_manual/records.xml
index e2fe5fe8de..e901b7bccf 100644
--- a/system/doc/reference_manual/records.xml
+++ b/system/doc/reference_manual/records.xml
@@ -145,6 +145,29 @@ is_person(_P) ->
</section>
<section>
+ <title>Nested records</title>
+ <p>Beginning with R14 parentheses when accessing or updating nested
+ records can be omitted. Assuming we have the following record
+ definitions:</p>
+ <pre>
+-record(nrec0, {name = "nested0"}).
+-record(nrec1, {name = "nested1", nrec0=#nrec0{}}).
+-record(nrec2, {name = "nested2", nrec1=#nrec1{}}).
+
+N2 = #nrec2{},
+ </pre>
+ <p>Before R14 you would have needed to use parentheses as following:</p>
+ <pre>
+"nested0" = ((N2#nrec2.nrec1)#nrec1.nrec0)#nrec0.name,
+N0n = ((N2#nrec2.nrec1)#nrec1.nrec0)#nrec0{name = "nested0a"},
+ </pre>
+ <p>Since R14 you can also write:</p>
+ <pre>
+"nested0" = N2#nrec2.nrec1#nrec1.nrec0#nrec0.name,
+N0n = N2#nrec2.nrec1#nrec1.nrec0#nrec0{name = "nested0a"},</pre>
+ </section>
+
+ <section>
<title>Internal Representation of Records</title>
<p>Record expressions are translated to tuple expressions during
compilation. A record defined as</p>