aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorgingerBill <ginger.bill.22@gmail.com>2016-08-23 00:03:53 +0100
committergingerBill <ginger.bill.22@gmail.com>2016-08-23 00:03:53 +0100
commitaaecb18c8f37a7f7feb3400178633819859b642f (patch)
tree57667583efc5199150bd1b4d7fcbc93b97a1575d /examples
parent81c592b5e92411e4b64744a152bd445bb6154433 (diff)
Fix procedure's scope
Diffstat (limited to 'examples')
-rw-r--r--examples/demo.odin22
1 files changed, 14 insertions, 8 deletions
diff --git a/examples/demo.odin b/examples/demo.odin
index 2867f8c81..2388e0fe4 100644
--- a/examples/demo.odin
+++ b/examples/demo.odin
@@ -124,6 +124,14 @@ procedures :: proc() {
return x + y;
}
+ fibonacci :: proc(n: int) -> int {
+ if n < 2 {
+ return n;
+ }
+ return fibonacci(n-1) + fibonacci(n-2);
+ }
+ print_int(fibonacci(12)); nl();
+
swap_strings :: proc(x, y: string) -> (string, string) {
return y, x;
@@ -554,19 +562,17 @@ data_control :: proc() {
context.allocator = __default_allocator();
defer context.allocator = prev_allocator;
- /*
- type File: struct { filename: string }
- type FileError: int
- open_file :: proc(filename: string) -> (File, FileError) { ... }
- close_file :: proc(f: ^File) { ... }
+ File :: type struct { filename: string };
+ FileError :: type int;
+ open_file :: proc(filename: string) -> (File, FileError) {
+ return File{}, 0;
+ }
+ close_file :: proc(f: ^File) {}
f, err := open_file("Test");
if err != 0 {
// handle error
}
defer close_file(^f);
- */
-
-
}
for i := 0; i < 100; i++ {