Merge branch 'master' of lukelau.me:/srv/git/scheme
authorLuke Lau <luke_lau@icloud.com>
Tue, 30 Jul 2019 21:25:15 +0000 (22:25 +0100)
committerLuke Lau <luke_lau@icloud.com>
Tue, 30 Jul 2019 21:25:15 +0000 (22:25 +0100)
1  2 
abi.md

diff --combined abi.md
index eafb1748dbe009d527203948dd705cbed99ce486,28f81c4152683ee00ae2a3c77daa166fd6f92959..c2ff16575c1da283f8c4d9c63a06d24c5ebe96ce
--- 1/abi.md
--- 2/abi.md
+++ b/abi.md
@@@ -11,6 -11,15 +11,15 @@@ when allocating, use first free block, 
  when freeing, do ???
  
  
+ # ownership
+ ```
+ (let ([s "hello"])  <- s should be a linear string
+   (mkpair
+     (lambda () (print s))               <- two references to s?
+     (lambda () (print (reverse s)))))
+ ```
  # closures
  
  * lambda: actual function containing the code
@@@ -26,19 -35,6 +35,19 @@@ lambda code  1st        2nd       3r
  address      captive    captive   captive   ...
  ```
  
 +## note on recursive closures
 +
 +The following example shows a recursive lambda, that results in a
 +closure that captures itself.
 +```
 +(let ([f (closure lambda0 (f))])
 +  (f 42))
 +```
 +When this happens, `codegen-let` will insert `(f . 'self-captive)`
 +into the environment when codegen'ing the closure. `codegen-closure`
 +will then pick this up, and use it to insert its own heap address into
 +its inner environment.
 +
  # lambdas
  
  lambdas use the system v amd64 calling convention.