[erlang-questions] Gotta be an easier way...
Mike Oxford
moxford@REDACTED
Mon Jun 13 23:34:26 CEST 2011
Updating nested records; keep all record (and sub-record!) information
intact but change one value.
A generic logon-type message, with nested records, this type of structure.
v1_rec_system_message_user_logon
v1_rec_header (header)
value1
v1_rec_route [] (route)
body
Orig#v1_rec_system_message_user_logon{header=Orig#v1_rec_system_message_user_logon.header#v1_rec_header{route=Orig#v1_rec_system_message_user_logon.header#v1_rec_header.route#v1_rec_route{route_entries=[foo]}}}.
Note how many times I have to fully qualify the record path to get the
sub-records to take the correct values even though I'm only changing
one value since every nested records seems to need to have a fully
qualified path. Ugh.
Shortening variable names, or writing accessor macros for everything
are possibilities ... but is there a better way I'm missing? (Don't
use nested records is a poor response.)
Note that....
Orig#v1_rec_system_message_user_logon.header#v1_rec_header.route#v1_rec_route{route_entries=[foo]}.
will give you
#v1_rec_route{value1 = correct,route_entries = [foo]}
but will not return the entire thing.
Anyone have a better way...?
Thanks!
-mox
More information about the erlang-questions
mailing list