X-Git-Url: https://git.lukelau.me/?p=scheme.git;a=blobdiff_plain;f=abi.md;h=eafb1748dbe009d527203948dd705cbed99ce486;hp=0185ec03acc4803a0bcc45f710d19d2ab23e77e1;hb=556da1eb404e9b6c132cd075d7666de4c5b904d2;hpb=8c2beb7c6589872bd9134e1c825c8a50adb11cc0 diff --git a/abi.md b/abi.md index 0185ec0..eafb174 100644 --- a/abi.md +++ b/abi.md @@ -26,6 +26,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.