mirror of
https://github.com/krgamestudios/Toy.git
synced 2026-04-15 14:54:07 +10:00
WIP return keyword, read more
Functions are having issues with being copied around, especially between buckets, leading to the scopes getting looped. The program gets stuck in 'incrementRefCount()'. It's past my time limit, so I'll keep working on it tomorrow with a fresh mind. All function stuff is still untested. See #163
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
/*
|
||||
|
||||
fn name(param1: int, param2: float, param3: string, param4) {
|
||||
print param1;
|
||||
print param2;
|
||||
@@ -7,8 +9,6 @@ fn name(param1: int, param2: float, param3: string, param4) {
|
||||
|
||||
name(42, 3.14, "hello world", -1);
|
||||
|
||||
//URGENT: return values are still needed
|
||||
|
||||
fn output(arg) {
|
||||
print arg;
|
||||
}
|
||||
@@ -20,4 +20,22 @@ output(3.1415);
|
||||
output("woot!");
|
||||
output([1, 23, 3]);
|
||||
output(["key":1]);
|
||||
output(name);
|
||||
output(name);
|
||||
|
||||
*/
|
||||
|
||||
fn makeCounter() {
|
||||
var counter: int = 0;
|
||||
|
||||
fn increment() {
|
||||
return counter++;
|
||||
}
|
||||
|
||||
return increment;
|
||||
}
|
||||
|
||||
var tally = makeCounter();
|
||||
|
||||
print tally();
|
||||
print tally();
|
||||
print tally();
|
||||
Reference in New Issue
Block a user