fuzion icon indicating copy to clipboard operation
fuzion copied to clipboard

match multiple things at once? (to enhance readability)

Open michaellilltokiwa opened this issue 2 months ago • 1 comments

currently

      match a
        av T =>
          match b
            bv T => T.equality av bv
            nil  => false
        nil =>
          match b
            _ T => false
            nil  => true

could be sth like:

      match a, b
        av T, bv T => T.equality av bv
        av T, nil => false
        nil, T => false 
        nil, nil  => true
``

michaellilltokiwa avatar Oct 06 '25 07:10 michaellilltokiwa

If we did this, I would suggest that this is a form of destructuring, i.e., a, b should be a tuple (a, b) and match should support destructuring and pattern matching for the destructured elements, so the code would look like this:

      match (a, b)
        av T, bv T => T.equality av bv
        av T, nil => false
        nil, T => false 
        nil, nil  => true

Some ideas on destructuring are in the design pages.

fridis avatar Oct 06 '25 11:10 fridis