| arc2c update |
| 9 points by almkglor 6104 days ago | 77 comments |
|
| I've made several updates to arc2c this weekend, especially since today we have a holiday in our country, so I had a 3-day weekend. My family's a bit pissed at me I think though ^^. Here's the new stuff: 1) Restructured some bits of the 'compile-file function. Adding new transformations is now easy,. 2) Arc style 'if is now fully supported: (if
(foo)
1
(bar)
2
'else)
3) ssyntax is now supported: (prn:foo 1), prn!hehe4) 'load and 'require, if on the top level of the file, now insert the contents of the specified files. 5) variadic functions now work: (set in
(fn (exp . rest)
(let self nil
(set self
(fn (exp rest)
(if (no rest)
nil
(is exp (car rest))
t
(self exp (cdr rest)))))
(self exp rest))))
(set list
(fn rest
rest))
6) 'set now works on local variables, see example of 57) Unused globals which are assigned to, but not read, are removed; also, for 'do blocks, if an expression is not in the tail position and doesn't have potential side effects - basically, literals, quote forms, variable references, and 'fn that aren't called or stored in variables - are removed: (do
1 2 3 4 5)
=>
(do 5)
This "optimization" is necessary so that we can simply mindlessly insert library functions (arc.arc contents, as well as some xdef'ed functions in ac.scm) to the source code, and this step will remove the unused library functions, removing code bloat which will probably just make debugging difficult.This step will of course need to be removed/skipped if 'eval is at all used, but most programs won't use eval anyway. TODO (by my expected priority): 1) Decoupling of primitives from globals, i.e. allow say, 'car and 'cdr to be redefined, instead of automatically making them primitives whenever they are encountered in function position. 2) Macros. Especially 'def. Also 'eval-when. Hmm. 3) Strings. Ooh, look ma, big unicode headaches!! 4) Threads 5) I/O |