Bug: The `list-iter` function presented assumes that an empty list is false. While that's the case in Common Lisp, it isn't in Scheme (and hasn't been in a very long time; iirc in early versions it was optional behavior).
Advanced Scheme Techniques (2004) [pdf]
11–20 of 21 posts
Re: Advanced Scheme Techniques (2004) [pdf]
#12Speaking from personal experience, Scheme looks deceptively simple but it is one of the hardest languages to write a compiler for. I say this mainly because of 2 things: 1. Hygienic Macros (You practically have a whole another language inside the language) 2. First Class Continuations (There is no good way to achieve this other than doing a CPS transform on the AST)
The other thing that makes languages like scheme difficult to compile are those closures. In fact, the book, the implementation of functional programming languages, Jones (1987) didn't do it at all! No closure conversion at all. They just compiled to a letrec in the g-machine.
Re: Advanced Scheme Techniques (2004) [pdf]
#13Bug: The `list-iter` function presented assumes that an empty list is false. While that's the case in Common Lisp, it isn't in Scheme (and hasn't been in a very long time; iirc in early versions it was optional behavior).
Slides author here. Thanks for flagging that. I'll fix it before I give the talk again, most likely in 2044 :)
Re: Advanced Scheme Techniques (2004) [pdf]
#14Bug: The `list-iter` function presented assumes that an empty list is false. While that's the case in Common Lisp, it isn't in Scheme (and hasn't been in a very long time; iirc in early versions it was optional behavior).
Slides author here. Thanks for flagging that. I'll fix it before I give the talk again, most likely in 2044 :)
Re: Advanced Scheme Techniques (2004) [pdf]
#15Speaking from personal experience, Scheme looks deceptively simple but it is one of the hardest languages to write a compiler for. I say this mainly because of 2 things: 1. Hygienic Macros (You practically have a whole another language inside the language) 2. First Class Continuations (There is no good way to achieve this other than doing a CPS transform on the AST)
CPS transformation is a good thing to do anyway, no? Then CPS your CPS and you have delimited continuations.
Re: Advanced Scheme Techniques (2004) [pdf]
#16Speaking from personal experience, Scheme looks deceptively simple but it is one of the hardest languages to write a compiler for. I say this mainly because of 2 things: 1. Hygienic Macros (You practically have a whole another language inside the language) 2. First Class Continuations (There is no good way to achieve this other than doing a CPS transform on the AST)
As far as compiling continuations goes, sequent calculus (specifically as a compiler IR) is an interesting research direction. See Grokking the Sequent Calculus (Functional Pearl) from ICFP 2024: https://dl.acm.org/doi/abs/10.1145/3674639 "This becomes clearer with an example: When we want to evaluate the expression (2 + 3) ∗ 5, we first have to focus on the subexpression 2 + 3 and evaluate it to its result 5. The re…
Re: Advanced Scheme Techniques (2004) [pdf]
#17Speaking from personal experience, Scheme looks deceptively simple but it is one of the hardest languages to write a compiler for. I say this mainly because of 2 things: 1. Hygienic Macros (You practically have a whole another language inside the language) 2. First Class Continuations (There is no good way to achieve this other than doing a CPS transform on the AST)
It's not true that you need to use CPS to implemented first-class continuations. There are plenty of slow ways to do it, and even if you want to be fast you can do multiple different things. Dybvig describes a number of options in his thesis: https://www.cs.unc.edu/xcms/wpfiles/dissertations/dybvig.pdf
If I am not mistaken, the racket language does not convert to CPS during compilation. Instead, when you want to get the continuation, I think you just get a pointer to the stack frame that you want. All I know for sure is that it uses something called a-normal form, which is kind of like SSA in some ways, and that the continuation is 2x 64/32-bit words depending on your architecture.
Re: Advanced Scheme Techniques (2004) [pdf]
#18Earlier quoted context omitted.
CPS transformation is a good thing to do anyway, no? Then CPS your CPS and you have delimited continuations.
Go straight for delimited continuations, which give you global ones for free.
A direct implementation is harder, but probably more useful.
Re: Advanced Scheme Techniques (2004) [pdf]
#19Speaking from personal experience, Scheme looks deceptively simple but it is one of the hardest languages to write a compiler for. I say this mainly because of 2 things: 1. Hygienic Macros (You practically have a whole another language inside the language) 2. First Class Continuations (There is no good way to achieve this other than doing a CPS transform on the AST)
Re: Advanced Scheme Techniques (2004) [pdf]
#20Bug: The `list-iter` function presented assumes that an empty list is false. While that's the case in Common Lisp, it isn't in Scheme (and hasn't been in a very long time; iirc in early versions it was optional behavior).
Slides author here. Thanks for flagging that. I'll fix it before I give the talk again, most likely in 2044 :)