Comment

Comment by aetherson

Sure, like this:

  %__MODULE__{buffer | size: buffer.size + 1, queue: :queue.in(item, buffer.queue)}
So that involves a bunch of operators that are very specialized to Elixir -- the %, the | are both very unclear in my opinion. And the __MODULE__ construction is clumsy.

Or worse:

  {:ok, {
      :ets.lookup_element(buffer.ets, pull_index, 2),
      %__MODULE__{buffer |
        size: buffer.size - 1,
        pull_index: rem(pull_index + 1, buffer.max_size)
      }
    }}
Same problem as above, plus the nested set structures that Erlang loves, but which rapidly become super difficult to decipher. Oh, and also the overloading of atoms to work like pseudo-objects.
parent aetherson 10 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton