[erlang-questions] Here's hoping we get frames or structs in 2009!

James Hague james.hague@REDACTED
Mon Jan 12 16:27:34 CET 2009


> Perhaps I am missing the obvious but I fail to see how the presence of
> the record name prevents you from doing this today -- especially for
> things that have a fixed number of "properties" (e.g. width, height,
> colors) as the above.

Records are passable for simple cases, like the example I gave, though
having to share record definitions between modules is a pain, and
necessitates a makefile or equivalent instead of recompiling a single
module.  That's so anti-Erlang, which is why I prefer association
lists and a light wrapper around lists:keysearch (or proplists, which
I'm less keen on).

The biggest downside to records is that they're fixed and brittle.  I
want to have widely varying contents, where I can query the "color"
property, even though I don't know what the other properties may be.
At the moment I can define 10 different records, and even though they
all have a "color" field there's no way to get at it without matching
on record type first.

James



More information about the erlang-questions mailing list