Hello,
The rationale behind the proposal is the fact there are cases the records
can be inappropriate. They provide excellent interface, but well, sometimes
the tag atom at first position (index 0) rather harms than helps.
One such use case I found when dealing with ETS tables.
ETS entries are tuples. While entries are homogenic, one record definition
which tuple data looks like {:tag, key, field1, ...} seems to be a good fit
and only one has to tell ETS the key is at second position (index 1).
However, when it comes to store many tuples of different shapes in one
table, the key itself should differentiate these shapes and the instance
within given shape, something like {:tag, key}, and then the alone :tag
field of a record becomes quite redundant. In such heterogenic ETS tables,
existing records have also their own use: for example to hold singular
entries each with "global" counters as fields.
Obviously, this is the real use case I encountered. Perhaps there are
others. I have no doubt that generally records, in cases one wants to use
tuples via functional interface, will be default practice.
I have code ready because I used the stuff earlier from an auxiliary
module. In Elixir the Tuple module and deftuple(p) seem natural, but I was
never good at naming things...
What do you think?
--
You received this message because you are subscribed to the Google Groups
"elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/elixir-lang-core/CABR-7m0R8j52Y2r57-hWomJ-nz%2B0R0Q5Q01B-xm5CAZH0jGHbw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.