Index
Blog

# Dynamic vs Static Scoping Test Case

As promised, here is your test case for comparing dynamic and static scoping. First, the version that uses bind before elaboration:

When I parse this example I get the following structure:

When I elaborate that result I get the following structure:

My statically scoped interpreter gives me 8 and my dynamically scoped interpreter gives me 4.

I’ve tried to get the indentation set up so both arguments to each app are lined up. Still, I suspect what you want is the concrete syntax for this expression:

If you’re using the string parser, you’ll need to get rid of the line breaks and turn the expression into a string using quotes.

For what it’s worth, I got this expression by writing an elaborator rather than trying to hand translate the bind expressions into app and lambda.