[erlang-questions] Robustness problems when using records [WAS: Re: Question/Alternative on Frames Proposal [Warning: Long]]
Kostis Sagonas
kostis@REDACTED
Sat May 19 17:26:01 CEST 2012
On 05/18/2012 02:21 AM, Tom Parker wrote:
> ....
>
> Where I think we would vehemently agree: I expect Erlang to be robust.
> That's why I'm even here. An issue with records where you can compile
> two files (using the same .hrl) and end up with a result that (a)
> compiles, (b) doesn't produce an error and (c) produces the wrong
> answer... is a serious issue. It distinctly shows the shortcomings of
> records.
Not really related to the frame discussion, but I would like to point
out that the above statement is wrong. The situation you describe does
not show shortcomings of records; instead it shows shortcomings of
programming with .hrl files and without an appropriate 'make'-like
utility to track dependencies between files.
Records are not without problems, but IMO this is not one of them. This
is a problem of using .hrl files and choosing to program in a way which
is not disciplined and thus error prone. There is a very simple way of
avoiding this problem that IMO is a very nice way of programming: Use
records as abstract data types and have them in a single module that
exports appropriate getters and setters for manipulating fields of the
record. If, for whatever reason, you do not like this way of using
records and want the ability to perform pattern matching and field
extraction in more than one module as you do today with records, better
make sure you use an appropriate Makefile (or equivalent) for compiling
your application. It's not the fault of record syntax if you do not use
such a mechanism! (Makefiles are technology of the 70's after all...)
Kostis
More information about the erlang-questions
mailing list