I have heard that specifying records through tuples in the code is a bad practice: I should always use record fields (#record_name{record_field = something}
) instead of plain tuples {record_name, value1, value2, something}
.
But how do I match the record against an ETS table? If I have a table with records, I can only match with the following:
ets:match(Table, {$1,$2,$3,something}
It is obvious that once I add some new fields to the record definition this pattern match will stop working.
Instead, I would like to use something like this:
ets:match(Table, #record_name{record_field=something})
Unfortunately, it returns an empty list.