-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTODO
More file actions
46 lines (41 loc) · 1.9 KB
/
TODO
File metadata and controls
46 lines (41 loc) · 1.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# TODO - basics
- ((eval '+) 1 2) doesn't rely on a compile-time `n` arg count
- Allow for empty lambda arg exprs
- Add variadic args in lambda defns
- Allow [] and ()
- a b c... where c collects all other args so you can do things like print macro
# Done TODOs
- Support equaliy of cons's , i.e. all members are equal
-
# Impl
- Use UserList and other classes to avoid leaning too much on Python builtins for the runtime.
- Compile arguments in reverse order so they do as expected in variadics, e.g.:
- (print a b) -> a b, not -> b a
- Bind operator builtins to symbol keywords
- Add primitive for Pair? Symbol? Int? Str? as well as Symbol->Val casts
# Bugs
- ((foo)) does not apply proc to (foo) -- just resolves to (foo)
- (lambda foo (a b c) 1) does not err out when called as (foo) -- no arg popping?
- Does not execute, just returns the fn: (print ((lambda (x) (+ x 1)) 1))
- This does not eval properly: (let x ( (lambda (a) 1))) -- it binds x to a function, not the proc.
the parse: ASTExpr(ASTOp('let'), ASTIdentifier('x'), ASTExpr(ASTExpr(ASTExpr(ASTOp('lambda'), ASTExpr(ASTIdentifier('a'), ASTIdentifier('b')), ASTConstantValue('int', '1'))))),
Need to fix the idea of an Expr and an Application, etc.
Rigorously understand the rules for Scheme and use that
- Symbols defined in global scope bind to function parameter names, e.g.
```
(let x 1)
(let foo (lambda (x) ...))
(foo) ; compiles and runs
```
# Frontend
- Parse lambdas with empty lists for either params or body
- Auto-generate handlers for bytecode for Python backend (case stmts, function stubs, etc.)
# Ideation
- Compile error message metadata, e.g. what would be most helpful based on the situation of opcodes and likely errors? For example, shadowing a global ID with a function parameter, and trying to call it.
# Accomplished
- Functions are first-class;
```
(let say (lambda (msg) (print msg)))
(apply say "hello, world!")
> "hello, world!"
```