Can any AST be refactored to a purely prefix or postfix execution?
So I have been writing a programming language as a hobby. It really isn’t much but in short the idea is that any program can be expressed in either infix, prefix, or in postfix format. While at runtime all code is executed in postfix.
I am wondering if there isn’t any code which cannot be refactored to be able to run postfix?
I was wondering this because I have been thinking about type and memory safety. Thinking regardless of how a program is compiled if the AST can be refactored to a postfix format then it would be easier to know if something if both defined and in a valid state.
Or conversely if made prefix then abstracted away variable scope using combinators the state and validity of data can be validated as a look ahead.
Such a check would be monitoring a variable in three formats definition, domain and range. Which the compiler can do at compilation.
I’m learning towards postfix checking because then much of the work just revolves around monitoring to state of the stack. Which seems easier than lambda abstraction evaluation.
submitted by /u/maxjmartin
[link] [comments]