dcreager.net

Should stack values be modeled as quotations?

Now that Swanson is concatenative, it operates on a stack of values. I want it to be possible for those to be nested: that is, you can have a stack as a value in another stack.

In typical concatenative languages, a quotation (an abstracted-over piece of concatenative code) is the same thing as a stack value. But that's largely because, like the lambda calculus, there are no other kinds of value! Every piece of data your program operates on must be Church-encoded: into a stack value for a concatenative language, or into a lambda term in the lambda calculus.

How would this work in a linear language like Swanson? The cases for and against:

Stack values cannot be quotations

Stack values can be quotations

Decision

In Swanson, stack values are a distinct thing, and are not modeled as quotations. Partly so that we can come up with a linear basis of S₀ instructions that manipulate stack values.

A linear basis for Swanson

..