<div dir="ltr">+1<br><br>
May 2009 be the Year of the Lightweight Hash :)<br>
<br>
<br><br><div class="gmail_quote">On Mon, Jan 12, 2009 at 1:10 AM, James Hague <span dir="ltr"><<a href="mailto:james.hague@gmail.com">james.hague@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
I've been using Erlang as my primary language for personal projects<br>
for some years now, though I also use and enjoy Perl, Python, REBOL,<br>
C++, Lua, and occasionally Forth.  Quite often I'm surprised at how<br>
much easier it is write certain types of code in Erlang...and I'm also<br>
surprised at how awkward it is to write other types of code in Erlang.<br>
 Sometimes the awkwardness is because I just can't think of a pretty<br>
way to avoid destructive updates in an algorithm that's inherently<br>
destructive.  But much of the time it's from working around the lack<br>
of lightweight dictionaries or hashes.<br>
<br>
In Perl, I don't think twice about creating hashes:<br>
<br>
   (width => 1280, height => 1024, colors=655536)<br>
<br>
The Python version is similarly clean:<br>
<br>
   dict(width=1280, height=1024, colors=65536)<br>
<br>
In Erlang, I can create a property list:<br>
<br>
   [{width,1280}, {height,1024}, {colors,65536}]<br>
<br>
which isn't bad in itself, but not being able to pattern match on<br>
these is what hurts.I work around it by manually grabbing properties,<br>
but the code ends up bulky and contrived.  Yeah, we've all discussed<br>
this for years, so here's hoping there's some movement on this front.<br>
Syntactically, the version I like the most at the moment is the record<br>
syntax without a record name:<br>
<br>
   #{width=1280, height=1024, colors=65536}<br>
<br>
James<br>
_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
<a href="http://www.erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://www.erlang.org/mailman/listinfo/erlang-questions</a><br>
</blockquote></div><br></div>