diff options
author | Erlang/OTP <[email protected]> | 2010-04-23 04:32:51 +0000 |
---|---|---|
committer | Erlang/OTP <[email protected]> | 2010-04-23 04:32:51 +0000 |
commit | c725744dc889d43a66883ac54b778fca2083a2b4 (patch) | |
tree | c5c03b58be9db2832df98797d615300a048d92d5 /system | |
parent | 280317139a17259fd7bf1dd8bbc95bee52c053b0 (diff) | |
parent | 45c380d1b77198449fb8e3beadb39dc8f77abb72 (diff) | |
download | otp-c725744dc889d43a66883ac54b778fca2083a2b4.tar.gz otp-c725744dc889d43a66883ac54b778fca2083a2b4.tar.bz2 otp-c725744dc889d43a66883ac54b778fca2083a2b4.zip |
Merge branch 'ta/nested-records' into dev
* ta/nested-records:
Document R14 paren-less record access/update
Support nested record field access without parentheses
OTP-8597 ta/nested-records
Nested records can now be accessed without parenthesis. See the Reference
Manual for examples. (Thanks to YAMASHINA Hio and Tuncer Ayaz.)
Diffstat (limited to 'system')
-rw-r--r-- | system/doc/reference_manual/records.xml | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/system/doc/reference_manual/records.xml b/system/doc/reference_manual/records.xml index e2fe5fe8de..d01d883ef3 100644 --- a/system/doc/reference_manual/records.xml +++ b/system/doc/reference_manual/records.xml @@ -4,7 +4,7 @@ <chapter> <header> <copyright> - <year>2003</year><year>2009</year> + <year>2003</year><year>2010</year> <holder>Ericsson AB. All Rights Reserved.</holder> </copyright> <legalnotice> @@ -13,12 +13,12 @@ compliance with the License. You should have received a copy of the Erlang Public License along with this software. If not, it can be retrieved online at http://www.erlang.org/. - + Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License. - + </legalnotice> <title>Records</title> @@ -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> |