X-Git-Url: https://git.lukelau.me/?p=scheme.git;a=blobdiff_plain;f=abi.md;h=c2ff16575c1da283f8c4d9c63a06d24c5ebe96ce;hp=5f09227ae56f2b21e31e7eca856a2e9917f60eec;hb=8e106ca13666680051f91ab3f49ce2bd7e19ead7;hpb=91145e54f41ee88f1e279a80430b3f5ed4e7a8c6 diff --git a/abi.md b/abi.md index 5f09227..c2ff165 100644 --- a/abi.md +++ b/abi.md @@ -4,6 +4,22 @@ a heap is allocated at the start, and the address to the next free space on it is stored in `heap_start`. it needs to be updated/decremented whenever you put anything on the heap +## todo +- how should allocation be managed? +make free blocks a doubly linked list. (how big is a block?) +when allocating, use first free block, move up free pointer +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 @@ -19,6 +35,19 @@ lambda code 1st 2nd 3rd 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.