future icon indicating copy to clipboard operation
future copied to clipboard

Arity checking is fragile

Open josephwilk opened this issue 12 years ago • 1 comments

Ripping out the arity of the quoted argument is a very fragile way to get the arity.

https://github.com/eproxus/future/blob/master/lib/future.ex#L30

For example this will fail:

test "passing something that we cannot find arity of" do
  x = &hello/2
  Future.new(x)
end

The solution is push the arity into the quoted code. Just need to workout how to manually replace unquote_splicing.

I will continue playing with that.

josephwilk avatar Aug 05 '13 12:08 josephwilk

Adding arity attibute is a dumb solution? (at least as fallback) Better unquote_splicing may help, but it might not work if the "x" is passed as function arguments, etc.?

defmacro new(fun, arity) do
  wrap_fun(fun, arity)
end

parroty avatar Dec 15 '13 14:12 parroty