diff options
author | Tuncer Ayaz <[email protected]> | 2010-04-20 20:43:10 +0200 |
---|---|---|
committer | Tuncer Ayaz <[email protected]> | 2010-04-20 20:46:24 +0200 |
commit | 3829e5facc98f1c1d3113b648c0b9fa7362cad32 (patch) | |
tree | c4c7fbc68a246d46270fb4ea0ad8f882b40591e6 /system/doc | |
parent | 09ca69e2247860fb5494297279c8819a34777cc6 (diff) | |
download | otp-3829e5facc98f1c1d3113b648c0b9fa7362cad32.tar.gz otp-3829e5facc98f1c1d3113b648c0b9fa7362cad32.tar.bz2 otp-3829e5facc98f1c1d3113b648c0b9fa7362cad32.zip |
Support nested record field access without parentheses
Original patch from YAMASHINA Hio posted to erlang-patches@
on Tue Jun 12 11:27:53 CEST 2007:
http://www.erlang.org/pipermail/erlang-patches/2007-June/000182.html
http://fleur.hio.jp/pub/erlang/record2.patch
Only had to do minor changes to port the patch to the
current R14A development tree.
Also added compiler/record_SUITE:nested_access/2 to test
nested record access with or without parentheses.
With this change the following will work.
-record(nrec0, {name = <<"nested0">>}).
-record(nrec1, {name = <<"nested1">>, nrec0=#nrec0{}}).
-record(nrec2, {name = <<"nested2">>, nrec1=#nrec1{}}).
nested_access() ->
N0 = #nrec0{},
N1 = #nrec1{},
N2 = #nrec2{},
<<"nested0">> = N0#nrec0.name,
<<"nested1">> = N1#nrec1.name,
<<"nested2">> = N2#nrec2.name,
<<"nested0">> = N1#nrec1.nrec0#nrec0.name,
<<"nested0">> = N2#nrec2.nrec1#nrec1.nrec0#nrec0.name,
<<"nested1">> = N2#nrec2.nrec1#nrec1.name,
<<"nested0">> = ((N2#nrec2.nrec1)#nrec1.nrec0)#nrec0.name,
N1a = N2#nrec2.nrec1#nrec1{name = <<"nested1a">>},
<<"nested1a">> = N1a#nrec1.name,
N2a = N2#nrec2.nrec1#nrec1.nrec0#nrec0{name = <<"nested0a">>},
N2b = ((N2#nrec2.nrec1)#nrec1.nrec0)#nrec0{name = <<"nested0a">>},
<<"nested0a">> = N2a#nrec0.name,
N2a = N2b,
ok.
Signed-off-by: Tuncer Ayaz <[email protected]>
Diffstat (limited to 'system/doc')
0 files changed, 0 insertions, 0 deletions