reference type added and very basic pass by reference works in CGenerator. Much more work to go to make sure complicated cases work and return by reference
This commit is contained in:
1
tests/test_references.expected_results
Normal file
1
tests/test_references.expected_results
Normal file
@@ -0,0 +1 @@
|
||||
7
|
||||
23
tests/test_references.krak
Normal file
23
tests/test_references.krak
Normal file
@@ -0,0 +1,23 @@
|
||||
import io:*
|
||||
|
||||
/*fun byRef<T>(it: ref T) {*/
|
||||
/*it = it + 1*/
|
||||
/*}*/
|
||||
|
||||
/*fun byRef(it: * int) {*/
|
||||
/**it = *it + 1*/
|
||||
/*}*/
|
||||
|
||||
fun byRef(it: ref int) {
|
||||
it = it + 1
|
||||
}
|
||||
|
||||
// what about cosures closing over references?
|
||||
|
||||
fun main():int {
|
||||
var a = 6
|
||||
byRef(a)
|
||||
println(a)
|
||||
return 0
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user