Mercurial > repos > tabletprog
annotate samples/fib.tp @ 251:2557ce4e671f
Fix a couple of compiler bugs. topenv was getting initialized in multiple places. This resulted in multiple copies of modules getting created which caused problems for macro expansion. Additionally, arguments were not being marked as declared during code generation so assigning to an argument that was not closed over generated invalid C code.
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Fri, 11 Apr 2014 22:29:32 -0700 |
parents | 3a169ebb3224 |
children |
rev | line source |
---|---|
10 | 1 #{ |
2 fib <- :n { | |
3 if: n < 2 { | |
4 1 | |
5 } else: { | |
6 (fib: n-1) + (fib: n-2) | |
7 } | |
8 } | |
9 | |
10 main <- { | |
44
9dd370530f69
Fix escape codes in string literals. Don't print out the return value of main method. Fixup fib example to use print: method. Cleanup error handling in compiler slightly
Mike Pavone <pavone@retrodev.com>
parents:
10
diff
changeset
|
11 print: (string: (fib: 30)) . "\n" |
10 | 12 } |
13 | |
14 } |