Robpike/Lisp: Toy Lisp 1.5 interpreter in Go
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.