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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Robpike/Lisp: Toy Lisp 1.5 interpreter in Go

229 点作者 mastabadtomm将近 5 年前

8 条评论

kitd将近 5 年前
<i>It is a pedagogical experiment to see just how well the interpreter (actually EVALQOUTE&#x2F;APPLY) defined on page 13 of that book really works. The answer is: perfectly, of course.</i><p>Well timed! I&#x27;ve just been trying this out myself after reading Maxwell&#x27;s Equations of Software [1]. It&#x27;s fun realising that the &quot;base&quot; functions you&#x27;re doing in Go can be reduced to even more fundamental forms using the Lisp you&#x27;re implementing.<p>[1] <a href="http:&#x2F;&#x2F;www.righto.com&#x2F;2008&#x2F;07&#x2F;maxwells-equations-of-software-examined.html" rel="nofollow">http:&#x2F;&#x2F;www.righto.com&#x2F;2008&#x2F;07&#x2F;maxwells-equations-of-software...</a>
评论 #23552037 未加载
klodolph将近 5 年前
Interesting: <a href="https:&#x2F;&#x2F;github.com&#x2F;robpike&#x2F;lisp&#x2F;blob&#x2F;master&#x2F;lisp1_5&#x2F;parse.go#L24" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;robpike&#x2F;lisp&#x2F;blob&#x2F;master&#x2F;lisp1_5&#x2F;parse.go...</a><p><pre><code> &#x2F;&#x2F; Expr represents an arbitrary expression. type Expr struct { &#x2F;&#x2F; An Expr is either an atom, with atom set, or a list, with car and cdr set. &#x2F;&#x2F; Car and cdr can be nil (empty) even if atom is nil. car *Expr atom *token cdr *Expr } </code></pre> Instead of using interface types for expressions, there is a simple expression structure type with fields that may or may not be set depending on what type of value it is.<p>I probably never would have done it that way, I would probably use an interface type instead. This way actually saves space in cons objects… in the above version, a cons is 24 bytes, and below it would be 32:<p><pre><code> type Expr interface { } type Cons struct { car, cdr Expr } </code></pre> Not efficient compared to modern Lisp interpretations, but an interesting choice.
评论 #23557164 未加载
评论 #23554123 未加载
评论 #23555071 未加载
评论 #23554002 未加载
mseepgood将近 5 年前
He also implemented an APL-like interpreter in Go: <a href="https:&#x2F;&#x2F;github.com&#x2F;robpike&#x2F;ivy" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;robpike&#x2F;ivy</a>
评论 #23550939 未加载
评论 #23549131 未加载
chewxy将近 5 年前
I hope one day when I grow old I get to engage in fun pasttimes like what Rob did.
评论 #23552538 未加载
评论 #23550854 未加载
评论 #23551974 未加载
mseepgood将近 5 年前
He mentions &quot;pedagogical&quot; and &quot;teaching tool&quot;. Who is he teaching? I would love to be his student.
评论 #23552694 未加载
wejick将近 5 年前
He wrote unit test +1000
alrs将近 5 年前
GOMODULE111, who needs it? :)
评论 #23551026 未加载
评论 #23552601 未加载
moron4hire将近 5 年前
I read the title as &quot;Robopike&#x2F;Lisp&quot; at first and suddenly imagined this was some operating system slashfic set in Paul Verhoven film universe.