From c7f4d6e791bda37eb4e90cf2cd4037313e0d33f2 Mon Sep 17 00:00:00 2001 From: Yuichi Nishiwaki Date: Wed, 4 Dec 2013 20:33:24 +0900 Subject: [PATCH] add library implementation note --- etc/LIBRARY_IMPL.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 etc/LIBRARY_IMPL.md diff --git a/etc/LIBRARY_IMPL.md b/etc/LIBRARY_IMPL.md new file mode 100644 index 00000000..a7933b74 --- /dev/null +++ b/etc/LIBRARY_IMPL.md @@ -0,0 +1,15 @@ +# How to implement `define-library`? + +* define-library can be nested +* expressions inside define-library are compiled and evaluated in order sequentially +* import declarations inside define-library and on the top level are semantically the same +* each define-library creates one syntactic-env +* and the body is evaluated as if it's on the top level +* so each `toplevel definitions`' results are registered to the global table +* but their renamed symbols are known only to who imported the library. + +## export table + +* import syntax destructively registers renamed symbols taken from export table of the specified library to syntactic env of the library +* export syntax registers correspoindings of original and renamed symbols to export table of the current library +* therefore, we need some kind of `forward declaration` support, because export syntax is usually placed at the beginning of source code.