Skip to content

Commit 890db93

Browse files
Add stdlib gc (closes #247)
1 parent 813f46f commit 890db93

7 files changed

Lines changed: 1320 additions & 1 deletion

File tree

‎docs/specification/10-standard-library.html‎

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,28 @@
4444
- `str script` = The path to the currently executing script.
4545
- `str script_dir` = The directory containing the currently executing script.
4646

47+
### 10.2 Garbage collection
48+
49+
The `gc` standard-library module tracks symbols and uses the remaining source
50+
program to determine whether they have a future reference. Collection removes
51+
tracked symbols that have no future reference, including initialized symbols.
52+
References in imported modules are included. Source evaluated dynamically by
53+
`run` is not analyzed. Use `gc.ignore` or `gc.ignore_all` to protect symbols
54+
from collection.
55+
56+
#### 10.2.1 API
57+
58+
- `bool gc.track_new_symbols` = Whether newly created symbols are tracked. The default value is `true`.
59+
- `func bool gc.track_all()` = Track all existing symbols and return whether any additional symbols were tracked.
60+
- `func bool gc.track(str symbol)` = Track `symbol`. The call MUST raise a runtime error if `symbol` does not exist.
61+
- `func bool gc.ignore_all()` = Stop tracking all existing symbols and return whether any symbols were untracked.
62+
- `func bool gc.ignore(str symbol)` = Stop tracking `symbol`. The call MUST raise a runtime error if `symbol` does not exist.
63+
- `func bool gc.collect()` = Delete all tracked symbols without future references and return whether any symbols were deleted.
64+
4765

4866
</script>
4967

5068
<script src="./index.js"></script>
5169
<script src="../render-md.js"></script>
5270
</body>
53-
</html>
71+
</html>

0 commit comments

Comments
 (0)