mu/static-dispatch.mu

30 lines
574 B
Plaintext
Raw Normal View History

# Example program showing how multiple functions with the same name can
# coexist, and how we select between them.
#
# Expected output:
# 4
# 7
# 7
def test a:num -> b:num [
2015-10-30 04:23:48 +00:00
local-scope
2017-12-04 07:25:40 +00:00
load-inputs
2015-10-30 04:23:48 +00:00
b <- add a, 1
]
def test a:num, b:num -> c:num [
2015-10-30 04:23:48 +00:00
local-scope
2017-12-04 07:25:40 +00:00
load-inputs
2015-10-30 04:23:48 +00:00
c <- add a, b
]
def main [
2015-10-30 04:23:48 +00:00
local-scope
2017-12-04 07:25:40 +00:00
a:num <- test 3 # selects single-input version
2015-10-30 04:23:48 +00:00
$print a, 10/newline
2017-12-04 07:25:40 +00:00
b:num <- test 3, 4 # selects double-input version
2015-10-30 04:23:48 +00:00
$print b, 10/newline
2017-12-04 07:25:40 +00:00
c:num <- test 3, 4, 5 # prefers double- to single-input version
2015-10-30 04:23:48 +00:00
$print c, 10/newline
]