News for hackers. Stuff that matters.
Re:A small British firm shows that software bugs aren't inev... by andy_ppp on Thursday October 22, 2015 @06:52AM (#10431481)
While not integer/number specific I like the idea of Guards in Elixir:

    def sum(a, b) when is_integer(a) and is_integer(b) do
      a + b
    end

    def sum(a, b) when is_list(a) and is_list(b) do
      a ++ b
    end

    def sum(a, b) when is_binary(a) and is_binary(b) do
      a <> b
    end

    sum 1, 2
    #=> 3

    sum [1], [2]
    #=> [1,2]

    sum "a", "b"
    #=> "ab"
Re:A small British firm shows that software bugs aren't inev... by arethuza on Thursday October 22, 2015 @07:45AM (#10431629)
That's pretty nice - like CLOS multiple dispatch with arbitrary predicates rather than types.

Are there any restriction on what the code in the guards can do?

Re:A small British firm shows that software bugs aren't inev... by lectrick on Thursday October 22, 2015 @07:59AM (#10431673)
Yes.

But the guard code are just macros, so... ;)

But I do believe that Erlang underneath does have actual limits.

Re:A small British firm shows that software bugs aren't inev... by lifeisstillgood on Thursday October 22, 2015 @07:20AM (#10431540)
That's it - going to set aside some time for getting Elixr on my bare competence skill set. I love that