Skip to content

Commit 0ec10e4

Browse files
committed
first impl. of serialization & simpl.
1 parent c74748f commit 0ec10e4

13 files changed

Lines changed: 392 additions & 95 deletions

File tree

README.md

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
**Clo**sure **calc**ulus is an interpreted functional programming language.
66
See [test/](test/) for code examples (`*.clo`).
77

8-
## syntax, semantics, and implementation
8+
## syntax
99

1010
```
1111
<comment> := #[^\n]*\n
@@ -33,32 +33,9 @@ See [test/](test/) for code examples (`*.clo`).
3333
| @ <variable> <expr> // accesses a closure's environment variable
3434
```
3535

36-
+ AST-traversal based interpreter; no bytecode.
37-
+ 4 object types: Void, Integer, String, Closure.
38-
Structs can be realized by closures and `@`.
39-
+ Variables are references to objects,
40-
but behave like values because objects are immutable.
41-
Variables cannot be re-bound.
42-
+ `letrec` and `( <callee> <expr>* )` evaluate from left to right
43-
and use pass-by-reference for variables.
44-
+ Threshold-based tracing garbage collection with memory compaction.
45-
+ Tail-call optimization,
46-
closure size optimization (omitting unused environment variables),
47-
literal object pre-allocation.
48-
Note: for better error messages during debugging,
49-
use `letrec` to rewrite tail calls to
50-
preserve stack frames.
51-
+ The runtime state (including stack, heap, etc.)
52-
is copyable and movable, and can be executed step-by-step.
53-
So it's easy to suspend/resume executions.
54-
5536
## dependencies
5637

57-
The debug mode uses Clang-specific flags,
58-
so we use Make instead of CMake.
59-
This project was tested on Linux and macOS,
60-
but should also compile on Windows
61-
if you adjust the build tools.
38+
This project was tested on macOS.
6239

6340
+ `clang++` with C++20 support
6441
+ `make`

run_test.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,10 @@ def test() -> None:
3939
start = time.time()
4040
res = execute(["bin/clocalc", filepath], io["in"])
4141
end = time.time()
42-
if (
43-
(res[0] == 0) == (io["err"] == "") and
44-
res[1] == io["out"] and
45-
res[2] == io["err"]
46-
):
42+
if (res[0] == 0 and res[1] == io["out"]):
4743
print(f"OK ({end - start:.3f} seconds)")
4844
else:
49-
sys.exit(f'failed\nresult = {res}\ntruth = {(io["out"], io["err"])}')
45+
sys.exit(f'failed\nresult = {res}\n')
5046

5147
if __name__ == "__main__":
5248
print("# started testing debug version")

0 commit comments

Comments
 (0)