[ prog / sol / mona ]

prog


Stack effect type checking

1 2023-10-25 21:52

Concatenative languages, like Forth, have a convention of annotating word definitions with stack effects. For example, if a word like +== pops two things from the stack as "inputs" and pushes one as an "output," you would write a "type signature" (actually just a comment) such as ==( a a -- a ).

A newcomer to concatenative languages might see this and try to interpret these comments as type signatures that the interpreter can check against existing words every time a word is defined. However, this quickly breaks down for words essential to the DIY character of Forth, and necessary for productivity in most other such languages as well.

How far can such stack effect typechecking go before a language ceases to be concatenative?

22


VIP:

do not edit these