implemented procCall builtin

This commit is contained in:
Araq
2014-11-28 02:43:41 +01:00
parent d456b882b1
commit 105a0616a9
11 changed files with 63 additions and 52 deletions

View File

@@ -1,6 +1,9 @@
discard """
file: "tmultim2.nim"
output: "collide: unit, thing collide: unit, thing collide: thing, unit"
output: '''collide: unit, thing
collide: unit, thing
collide: thing, unit
collide: thing, thing'''
"""
# Test multi methods
@@ -12,25 +15,25 @@ type
a, b: int
method collide(a, b: TThing) {.inline.} =
quit "to override!"
echo "collide: thing, thing"
method collide(a: TThing, b: TUnit) {.inline.} =
write stdout, "collide: thing, unit "
echo "collide: thing, unit"
method collide(a: TUnit, b: TThing) {.inline.} =
write stdout, "collide: unit, thing "
echo "collide: unit, thing"
proc test(a, b: TThing) {.inline.} =
collide(a, b)
proc staticCollide(a, b: TThing) {.inline.} =
procCall collide(a, b)
var
a: TThing
b, c: TUnit
collide(b, c) # ambiguous (unit, thing) or (thing, unit)? -> prefer unit, thing!
test(b, c)
collide(a, b)
#OUT collide: unit, thing collide: unit, thing collide: thing, unit
staticCollide(a, b)