TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Show HN: Compiler Fundamentals – Closure Conversion

70 点作者 rain1超过 6 年前

5 条评论

rain1超过 6 年前
I took the essence of closure conversion and implemented it as a single file racket script with explanation in comments and examples.<p>The idea is that this should help someone if they are a beginner wanting to implement a language that has lambda. Or anybody who is curious how a compiler might implement lambda.
tinco超过 6 年前
Lisps look so magical. I wish it were more accepted in the web application industry to pick a lisps for implementing services. I love my Ruby, and my Go, but it would be fun to experiment with a lisp some time.
评论 #19182556 未加载
sinistersnare超过 6 年前
I also made a closure converting pass to my compiler (in racket also!)<p>Here&#x27;s mine: <a href="https:&#x2F;&#x2F;github.com&#x2F;sinistersnare&#x2F;SinScheme&#x2F;blob&#x2F;master&#x2F;src&#x2F;racket&#x2F;closure-convert.rkt" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;sinistersnare&#x2F;SinScheme&#x2F;blob&#x2F;master&#x2F;src&#x2F;r...</a>
评论 #19182611 未加载
rurban超过 6 年前
A shorter version in C: <a href="https:&#x2F;&#x2F;github.com&#x2F;perl11&#x2F;potion&#x2F;blob&#x2F;master&#x2F;core&#x2F;compile.c#L198" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;perl11&#x2F;potion&#x2F;blob&#x2F;master&#x2F;core&#x2F;compile.c#...</a>
disconcision超过 6 年前
this is just a tiny nitpick but I&#x27;m wondering why you didn&#x27;t use pattern matching? if you just wanted to stay schemey then disregard but you could skip the entire shapes section and the rest of the code would still be terser, e.g.<p><pre><code> ((begin? exp) `(begin . ,(mapply cc (cdr exp) sc))) </code></pre> would become<p><pre><code> [`(begin ,xs ...) `(begin ,@(mapply cc xs sc))] </code></pre> or if you&#x27;re feeling fancy<p><pre><code> (define cc-sc (curryr cc sc)) [`(begin ,(app cc-sc xs) ...) `(begin ,@xs)]</code></pre>