LET: Adding Local Bindings to a Tiny Interpreter in Elm

LET allows you to introduce local bindings and use them to name intermediate results.

I’m trying out a new format with this post. I introduce the feature, explain its intended semantics, and give you examples to test your understanding before walking through how I implemented it. There’s also a place to pause and try implementing it yourself.

3 Likes

Hit after hit after hit with these posts

2 Likes

@john-kelly Happy to hear you’ve been enjoying the posts.

I ended up exploring and writing about three different variations of multiple-binding let:

LETPAR and LETSEQ were the two variations I originally planned to explore. LETDEP came out of asking what would happen if forward references were allowed, which led to dependency graphs, topological sorting, free-variable analysis, and some interesting lexical-scope edge cases.

LETDEP also ends up fairly close to Elm’s let semantics, since definitions are not constrained by source order.

5 Likes

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.