On Sat, Jul 3, 2021, at 5:32 PM, silas poulson wrote:

On 2 Jul 2021, at 19:06, Ethan Gardener <eekee57@fastmail.fm> wrote:

This reminds me why I switched to Forth: I can program my editor properly

Could you expand on this point?

Vaguely aware of Forth, but no experience with forth editors

Sure. There's a few things.

I like and sometimes make use of the fact that the input language is a full systems language. I can access all the editor's variables and memory from the input prompt or from my own code. Sometimes it blows up because Forth has even fewer safeguards than C, but I soon learned how to avoid the explosions. It helps that I now use a Forth which displays the stack contents before each prompt; I do recommend that. All this can be summarized with a little misquote: "[Forth] does not prevent you doing stupid things because that would also prevent you doing clever things." ;) Sometimes I wish for type safety, but now I've learned to do without it, it's fine.

Other than that, I make some use of the data stack: I've written several words to leave string references on the stack for use by other words, chaining them together almost like a pipeline. Sam can do things like this so it's not too new, but I can chain anything I like and easily write new commands. I don't always chain them on the same line. If there's a memory copy or blank operation in there, I'll check the parameters look right first. The check doesn't take a second.

Where Sam executes commands in braces "at the same time," not allowing you to change the order, I've got full control of the order of execution. In Sam, I was never successful in changing text with commands in braces. Sam or Acme would always report something about multiple changes at the same time, and Sam would corrupt the text a bit. I don't remember exactly what I was trying to do, but I was sure it would have worked if my commands were executed in order. In Forth by contrast, there's nothing to get commands out of order. I may not be working on large files with complex commands any more, but I write sequences of simple commands all the time.

To be honest, it helps that the editor's source code is only about 2.5KB. ;) Some of that isn't even editor, it's block indexing and multi-block search, but I've replaced one and need to replace the other. Actually, I should rewrite the editor seeing as I don't want my code GPL-licensed and the editor probably is. ("Probably"? There's no license in the editor itself, likely because it's hard to fit licensing boilerplate into 1KB blocks.)