pass by reference should work for templates and objects now

This commit is contained in:
Nathan Braswell
2015-07-14 22:42:25 -04:00
parent 602810002b
commit 0ee44e829f
4 changed files with 50 additions and 22 deletions

View File

@@ -1 +1,6 @@
7
8
7.700000
construct
do
destruct

View File

@@ -1,12 +1,34 @@
import io:*
/*fun byRef<T>(it: ref T) {*/
/*it = it + 1*/
/*}*/
obj test_cons(Object) {
fun construct(): *test_cons {
println("construct")
}
fun copy_construct(other: *test_cons) {
println("copy_construct")
}
fun destruct() {
println("destruct")
}
fun operator=(other: test_cons) {
println("=")
}
fun do() {
println("do")
}
}
/*fun byRef(it: * int) {*/
/**it = *it + 1*/
/*}*/
fun call<T>(it: ref T) {
it.do()
}
fun byRef<T>(it: ref T) {
it = it + 1
}
fun byRef(it: * int) {
*it = *it + 1
}
fun byRef(it: ref int) {
it = it + 1
@@ -18,6 +40,14 @@ fun main():int {
var a = 6
byRef(a)
println(a)
byRef(&a)
println(a)
var b = 6.7
byRef(b)
println(b)
var t.construct() : test_cons
call(t)
return 0
}