Return by reference and pass by reference working with objects. Closures might present problems, however

This commit is contained in:
Nathan Braswell
2015-07-15 00:53:53 -04:00
parent 0ee44e829f
commit 06f36f2a87
12 changed files with 79 additions and 67 deletions

View File

@@ -34,6 +34,14 @@ fun byRef(it: ref int) {
it = it + 1
}
fun id(it: ref int): ref int {
return it
}
fun id<T>(it: ref T): ref T {
return it
}
// what about cosures closing over references?
fun main():int {
@@ -42,12 +50,15 @@ fun main():int {
println(a)
byRef(&a)
println(a)
id(a) = 14
println(a)
var b = 6.7
byRef(b)
println(b)
var t.construct() : test_cons
call(t)
id(t).do()
return 0
}