use 'using' instead of 'sig' keyword; cleans up new features a bit

This commit is contained in:
Andreas Rumpf 2016-02-29 12:19:54 +01:00
commit c9966a3e17
20 changed files with 109 additions and 74 deletions

View file

@ -11,7 +11,7 @@ discard """
type
E = enum A, B, C
proc foo(x): auto =
proc foo(x: int): auto =
return case x
of 1..9: "digit"
else: "number"

View file

@ -3,5 +3,5 @@ discard """
line: 6
"""
let x = proc (x, y): auto = x + y
let x = proc (x, y: auto): auto = x + y

View file

@ -18,7 +18,7 @@ proc foo[T](p: TType[T, range[0..2]]) =
#bug #1366
proc reversed(x) =
proc reversed(x: auto) =
for i in countdown(x.low, x.high):
echo i

View file

@ -5,15 +5,15 @@ discard """
proc test(x: proc (a, b: int): int) =
echo x(5, 5)
test(proc (a, b): auto = a + b)
test(proc (a, b: auto): auto = a + b)
test do (a, b) -> auto: a + b
test do (a, b: auto) -> auto: a + b
proc foreach[T](s: seq[T], body: proc(x: T)) =
for e in s:
body(e)
foreach(@[1,2,3]) do (x):
foreach(@[1,2,3]) do (x: auto):
echo x
proc foo =

View file

@ -26,7 +26,7 @@ proc noReturn(x: () -> void) =
proc doWithOneAndTwo(f: (int, int) -> int): int =
f(1,2)
echo twoParams(proc (a, b): auto = a + b)
echo twoParams(proc (a, b: auto): auto = a + b)
echo twoParams((x, y) => x + y)
echo oneParam(x => x+5)

View file

@ -0,0 +1,39 @@
discard """
output: '''0 -2 0
0 -2'''
"""
{.this: self.}
type
Foo {.partial.} = object
a, b: int
type
tupcomingfeatures.Foo = object
x: int
proc yay(self: Foo) =
echo a, " ", b, " ", x
proc footest[T](self: var Foo, a: T) =
b = 1+a
yay()
proc nongeneric(self: Foo) =
echo a, " ", b
var ff: Foo
footest(ff, -3)
ff.nongeneric
{.experimental.}
using
c: Foo
x, y: int
proc usesSig(c) =
echo "yummy"
proc foobar(c, y) =
echo "yay"

View file

@ -5,7 +5,7 @@ template someIt(a, pred: expr): expr =
var it {.inject.} = 0
pred
proc aProc(n) =
proc aProc(n: auto) =
n.someIt(echo(it))
aProc(89)

View file

@ -5,8 +5,8 @@ discard """
import typetraits
proc plus(a, b): auto = a + b
proc makePair(a, b): auto = (first: a, second: b)
proc plus(a, b: auto): auto = a + b
proc makePair(a, b: auto): auto = (first: a, second: b)
proc `+`(a, b: string): seq[string] = @[a, b]
@ -19,7 +19,7 @@ static: assert p[0].type is string
echo i.type.name
echo s.type.name
proc inst(a): auto =
proc inst(a: auto): auto =
static: echo "instantiated for ", a.type.name
result = a