Is it always useful to use association lists instead of entries?

Will any experienced Erlang programmers ever recommend lists of record associations ?

In one case, there may be a place where two (or more) nodes on different machines exchange messages. We want to be able to update software on each machine independently. Some updates may include adding a field to one (or more) sent messages. It seems like using a recording, as the message will mean that you should always perform the update on both machines at the blocking stage, so that the additional field does not cause the receiver to ignore the recording. If you used something like a list of associations (which still has an "entry-like" API), the receiver that has not yet been updated will still receive the message successfully and simply ignore the new field. I understand that this is not always the desired behavior, but often it is. Also, suppose the posts are pretty small,therefore, the search time does not matter.

Assuming this makes sense, I have the following additional questions:

  • Is there a standard (or widely used) library for alists? Some trivial googling did not appear.
  • Are there other cases where you would use a list of associations (or something like this)?
+5
source share
3 answers

You have basically three options:

  • Use Records
  • Use association lists (proplists)
  • Use combination

I use records where the probability of its change is very low. This way I get the pattern matching and acceleration I want.

I use proplists where I need a hash table as functionality. I get flexibility by matching patterns and speed.

. , . , , .

, . , , .

+5

aka proplists dict. , , . , .

+5

Note that: keysearch / 3 lists are pretty much "assq".

+3
source

All Articles