josevalim/elixir — Issue #100: Do not merge key-value args with key-value blocks
Author: josevalim
Created: 2012-01-13 20:30:55+00:00
State: open
Labels: Bug

Those two formats are equivalent:

function(foo: 1) do
2
else:
3
end

function(foo: 1, do: 2, else: 3)

However, for many APIs the block may be optional. Imagine defexception which will expect an optional block:

defexception NameError, message: nil

defexception NameError, message: nil do
# Some methods
end

The fact the block is optional and the merging, means the user will actually have written:

defexception NameError, message: nil, do: # Some methods

So, in order to not merge the arguments, he needs to write:

defexception NameError, [message: nil] do
# Some methods
end

Which is confusing. I believe we shouldn't merge those options and actually make those two equivalent instead:

function(foo: 1) do
2
else:
3
end

function([foo: 1], do: 2, else: 3)