|
|
|
|
|
by romforth
533 days ago
|
|
I have ported Forth to a dozen small microcontrollers and my experience
writing much of the bootstrap code in Forth tells me that you are better off
coding Forth in a "vertical" style (ie one word per line with stack picture
comments), rather than the terse "horizontal" code of "everything on one line"
that many of the folks using Forth (including @yosefk, the author) seem to prefer. Given how close Forth is to assembly (seen from an implementer's point of view)
it makes sense to write Forth in a "vertical" style which reflects the
"vertical" style in which assembly code is written. This has the advantage that
the "stack picture comments" on each line of code can stand in for Hoare triplets
so that the code and its - I'll call it - "proof" can be written hand in hand
at the same time. This is how all of the Forth code that I've written in
https://github.com/romforth/romforth is structured. It does make the code appear less compact though so you are not going to win
any code golf prizes. |
|
A text display with an auto pretty printed view would serve people who like both code styles well.
A newline per stack reducing operation with the next line indented by stack depth would make it close to your style and could be quite automatic.