[erlang-questions] What is best practice (records/tupples)?

Matthew Evans mattevans123@REDACTED
Mon Feb 6 17:52:30 CET 2012


Hi,
Given something like:
-record(my_record, {aaa,                    bbb,                    ccc,                    ddd}).

What is more efficient, and what is best practice? 
This -
some_function(#my_record{aaa = AAA, bbb = BBB, ddd = DDD} = _MyRecord) ->    % Some work

Or this -

some_function(MyRecord) ->    AAA = MyRecord#my_record.aaa,    BBB = MyRecord#my_record.bbb,    DDD = MyRecord#my_record.ccc,    % Some work

I've always thought that the first example is best. Or does the compiler do some kind of trickery?
Does it make any difference if you only need a few vs. all the variables from the record?
Thanks
Matt
 		 	   		  


More information about the erlang-questions mailing list