list - When to use an Erlang record instead of a tuple? -
when should use erlang record instead of tuple? or, visa-versa, when erlang record unnecessary? relatively new erlang , not sure if using records , tuples properly. understand have read records stored tuples behind scenes.
i typically use records pieces of data going passed around application or persisted somewhere. use tuples things return value of function, params of function, , things specific body of function.
am using records , tuples correctly? there documentation outlining when 1 type should used on another?
it style question. note:
- tuples of large arity hard correct , swap values. record names each field making swaps less likely.
- you can match on record subset of fields.
- a record needs same arity. such bad emulating sum types.
- records not shared on modules leads lots of .hrl files include statements if used between modules. breaks abstraction.
- records can kept module-local make harder others use record. improves modularity.
Comments
Post a Comment