So, I have a pretty deep hierarchy of record definitions:
-record(cat, {name = '_', attitude = '_',}).
-record(mat, {color = '_', fabric = '_'}).
-record(packet, {cat = '_', mat = '_'}).
-record(stamped_packet, {packet = '_', timestamp = '_'}).
-record(enchilada, {stamped_packet = '_', snarky_comment = ""}).
And now I have an enchilada, and I want to create a new one, just like the meaning of one of the subtasks. Here is what I did.
update_attitude(Ench0, NewState)
when is_record(Ench0, enchilada)->
%% Pick the old one apart.
%% Build up the new one.
Tude1 = Tude0
PK1 = PK0
SP1 = SP0
%% Thank God that over.
Ench0
Just thinking about it hurts. Is there a better way?
source
share