Is there someone who has made your Ruby experience great? Someone who doesn’t get the recognition they deserve? The Rails Envy guys are doing the Ruby Hero awards again, so go nominate someone!
Iteration in herml
herml is a Haml-like template language for Erlang that I’ve been developing with Kevin Smith. One of the major hurdles we’ve had to tackle is iteration, which is a pretty common idiom in template languages, but not so much in Erlang. In Erlang, one normally uses a tail-recursive function, lists:foreach(), or a list comprehension to iterate over a collection (list). Initially, Kevin had planned something like this:
[%tr
%td
@User || User <- @Users]However, that proved to be too difficult to parse:
- The opening bracket breaks with the style previously set forward.
- The comprehension piece comes at the end, making it hard to know ahead of time what is being iterated over
Instead, on Thursday (erloungeRDU hack night), we agreed to do this simpler, but still LC-like syntax:
- [@User] <- @Users
%td
@UserThis proved to be much easier to parse and implement. We even have structured decomposition, like so:
- [{@Id, @Login}] <- @Users
%td
@Id
%td
@LoginAnd match ignores with _:
- [{_, @Login}] <- @Users
%td
@LoginThere’s still a lot to do, but it’s shaping up nicely. Check it out!
