The template part of the new syntax! Gotta go transform all of stdlib and the tests now and see if any other bugs pop up
This commit is contained in:
36
tests/test_newSyntaxTemplate.krak
Normal file
36
tests/test_newSyntaxTemplate.krak
Normal file
@@ -0,0 +1,36 @@
|
||||
|
||||
|
||||
typedef Swapper<T> {
|
||||
fun doit(a: T*, b: T*) : void {
|
||||
var temp: T = *a;
|
||||
*a = *b;
|
||||
*b = temp;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fun swap<T>(a: T*, b: T*) : void {
|
||||
var temp: T = *a
|
||||
*a = *b
|
||||
*b = temp;
|
||||
}
|
||||
|
||||
fun print2int(a: int, b: int) : void {
|
||||
simple_passthrough(a = a, b = b::) """
|
||||
printf("yeah new syntax: %d, %d\n", a, b);
|
||||
"""
|
||||
}
|
||||
|
||||
|
||||
fun main() : int {
|
||||
var i: int = 7;
|
||||
var j: int = 6;
|
||||
print2int(i,j)
|
||||
swap<int>(&i, &j)
|
||||
print2int(i,j)
|
||||
var it: Swapper<int>
|
||||
it.doit(&i,&j);
|
||||
print2int(i,j)
|
||||
return 0
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user