# Mu - static-dispatch.mu

     1 # Example program showing how multiple functions with the same name can
     2 # coexist, and how we select between them.
     3 #
     4 # Expected output:
     5 #   4
     6 #   7
     7 #   7
     8
     9 def test a:num -> b:num [
    10   local-scope
    11   load-inputs
    12   b <- add a, 1
    13 ]
    14
    15 def test a:num, b:num -> c:num [
    16   local-scope
    17   load-inputs
    18   c <- add a, b
    19 ]
    20
    21 def main [
    22   local-scope
    23   a:num <- test 3  # selects single-input version
    24   $print a, 10/newline
    25   b:num <- test 3, 4  # selects double-input version
    26   $print b, 10/newline
    27   c:num <- test 3, 4, 5  # prefers double- to single-input version
    28   $print c, 10/newline
    29 ]