Re:Writing an Interpreter in SQL for Fun and No Profit [video]
by wwweston on Tuesday June 04, 2019 @02:51PM
(#20098046)
Are you informed by any general work on using relational algebra + one or two other things (recursion via CTE and environments, I guess, in this case) as general purpose programming languages, or did this mostly start by thinking about hacking your way to the specific goal of an interpreter or fractal generator using postgres facilities at hand?
[ Parent
| on HN ]
Re:Writing an Interpreter in SQL for Fun and No Profit [video]
by malisper on Tuesday June 04, 2019 @03:06PM
(#20098176)
I'm not aware of any general work. I initially tried to directly port Paul Graham's interpreter into SQL. I immediately ran into problems because it wasn't possible to map the recursive function calls into SQL. After thinking about it in the background for a day, I figured out I could use the CTE +_stack approach instead of recursion. Once I figured that out, it only took me a few hours to port the interpreter.