Syntactic sugar for specifying tuple function arguments

Instead of

   function f(t::Tuple{Bool,Int})
      a = t[1]
      b = t[2]
   end

it would be nice to say:

  function f((a,b)::Tuple{Bool,Int})
  end

or even better:

  function f((a::Bool, b::Int))
  end
5 Likes

Looks like you want ML-style pattern matching. Not sure whether most people are interested in this, but Iā€™d support a PR that implements it.

2 Likes

https://github.com/JuliaLang/julia/issues/6614

2 Likes

It does seem useful from time to time. I wonder why python3 gets rid of it.

I think this would be useful.

1 Like

Definitely useful, mostly a matter of someone implementing it.

1 Like