Live data from Hacker News

Advanced Scheme Techniques (2004) [pdf]

people.csail.mit.edu

11–20 of 21 posts

Re: Advanced Scheme Techniques (2004) [pdf]

#11
post #5

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).

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]

#12
post #2

Speaking 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)

Very true but the other side of this is first class continuations are no worse than compiling try-catch semantics, and hygienic macros are still just macros so the complexity is kept simple (sort of. maybe simple isn't always so simple).

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]

#13
post #11
post #5

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).

Slides author here. Thanks for flagging that. I'll fix it before I give the talk again, most likely in 2044 :)

FYI, all the links in your bio 404.

Re: Advanced Scheme Techniques (2004) [pdf]

#14
post #11
post #5

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).

Slides author here. Thanks for flagging that. I'll fix it before I give the talk again, most likely in 2044 :)

Don't feel compelled to rush into giving it again that soon just because it got shared on HN.

Re: Advanced Scheme Techniques (2004) [pdf]

#15
post #7
post #2

Speaking 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.

Go straight for delimited continuations, which give you global ones for free.

Re: Advanced Scheme Techniques (2004) [pdf]

#16
post #9
post #2

Speaking 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…

There's an OOPSLA paper (referred to from the link starting that thread) from this year with 2 of the same authors that goes into more detail about using it as a compiler IR: https://dl.acm.org/doi/10.1145/3720507

Re: Advanced Scheme Techniques (2004) [pdf]

#17
post #10
post #2

Speaking 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

Sam will definitely know more about this than I will, so if he contradicts me, listen to him.

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]

#18
post #15
post #7

Earlier 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.

Oh. I meant not using call/cc, but by doing local CPS transformations. This is the simple way, but has limitations with dynamic uses of reset.

A direct implementation is harder, but probably more useful.

Re: Advanced Scheme Techniques (2004) [pdf]

#19
post #2

Speaking 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)

Use someone else's implementation of the macro stuff and focus on the compiler.

Re: Advanced Scheme Techniques (2004) [pdf]

#20
post #11
post #5

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).

Slides author here. Thanks for flagging that. I'll fix it before I give the talk again, most likely in 2044 :)

[deleted]
Post reply on HN