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

James Hague james.hague@REDACTED
Mon Jan 12 00:10:35 CET 2009


I've been using Erlang as my primary language for personal projects
for some years now, though I also use and enjoy Perl, Python, REBOL,
C++, Lua, and occasionally Forth.  Quite often I'm surprised at how
much easier it is write certain types of code in Erlang...and I'm also
surprised at how awkward it is to write other types of code in Erlang.
 Sometimes the awkwardness is because I just can't think of a pretty
way to avoid destructive updates in an algorithm that's inherently
destructive.  But much of the time it's from working around the lack
of lightweight dictionaries or hashes.

In Perl, I don't think twice about creating hashes:

   (width => 1280, height => 1024, colors=655536)

The Python version is similarly clean:

   dict(width=1280, height=1024, colors=65536)

In Erlang, I can create a property list:

   [{width,1280}, {height,1024}, {colors,65536}]

which isn't bad in itself, but not being able to pattern match on
these is what hurts.I work around it by manually grabbing properties,
but the code ends up bulky and contrived.  Yeah, we've all discussed
this for years, so here's hoping there's some movement on this front.
Syntactically, the version I like the most at the moment is the record
syntax without a record name:

   #{width=1280, height=1024, colors=65536}

James



More information about the erlang-questions mailing list