[elixir-core:8537] [Proposal] Simplify @spec def and @spec defp for efficiency and maintenance purpose

2019-03-13 Thread unifiedf
Instead of doing this: defmodule LousyCalculator do @spec add(number, number) :: {number, String.t} def add(x, y), do: {x + y, "You need a calculator to do that?!"} @spec multiply(number, number) :: {number, String.t} def multiply(x, y), do: {x * y, "Jeez, come on!"} end How about this

Re: [elixir-core:8537] [Proposal] Simplify @spec def and @spec defp for efficiency and maintenance purpose

2019-03-13 Thread Louis Pilfold
Hi As Elixir has reached version 1 there's not going to be a major change of syntax like this. You could implement this as a macro in your own project though :) use MyMacro def add(x :: number(), y :: number()) :: number() do x + y end Cheers, Louis On Wed, 13 Mar 2019, 08:34 , wrote: >