Hi,
Are you recovering an unknown FORTH code?
Looking to understand the meaning of the FORTH words in this code?
Well, I have developed a mill, in PHP, which will read this code and document it in a fraction of seconds!
https://eforth.arduino-forth.com/index/doc/
On 11/01/2024 10:51 am, Hans Bezemer wrote:
On Monday, November 27, 2023 at 9:16:47 AM UTC+1, minforth wrote:
I tested it with code snippets from F83 and an old but short 8QUEEN solver. >>> Your tool did not _document_ anything, but added hyperlinks to words,Yeah, it's useless. I'd write something like that in zero flat.
pointing deeper into your own Forth systems. Good for you.
But thanks anyway for releasing your tool to the public.
You might be interested in HolonForth for comparison.
However, I had good results with feeding code to ChatGPT
and let it figure out what it does. I stripped all comments
from it - but I guess well named words might give it enough
hints.
I won't call it documentation either, but for figuring out what
zero commented code actually does functionality wise, I think
it's quite handy.
App code I write are near zero commented. This is less problematic
in forth where functions tend to be short. Unless a function is very >obscurely named (Will Baden?), forth is largely self-documenting.
Nor is 'tricky' code really a problem. By the time one realizes it
was tricky, one will add the comment. If OTOH one never comes back to
it, who is there to care? I appreciate there may be external reasons
to add comments e.g. to impress the audience or the customer demanded
it. But that's more about pleasing others. IIRC Moore's source for >ColorForth had no comments.
I by habit usually add useless comments. It's something I
can do unthinkingly while I contemplate some aspect or usage
of the code just written; fingers like to stay busy.
On 12/01/2024 5:34 am, mhx wrote:
sjack wrote:
[..]
I by habit usually add useless comments. It's something I
can do unthinkingly while I contemplate some aspect or usage
of the code just written; fingers like to stay busy.
Do you change these comments when you afterwards change the code?
...
Good point. I find comments get included on subsequent revisions, >particularly as overall program complexity increases. These tend
to be one-liners at the beginning of a definition. More a reminder
than an explanation. I did 'technical writing' in my career aimed
at new readers. Nothing like that. I'd find it tedious.
In the past, we had code reviews as part of the product release.
Experienced engineers from the service department went through
the source code of the system to check that the code was
understandable and serviceable, e.g. remotely. The result was
often very sobering, but very positively instructive for everyone.
As an individual programmer in your one-man-show, you need more
discipline. But probably every old hand in the business has sat
in front of their own old code and puzzled over it.
sjack wrote:
[..]
I by habit usually add useless comments. It's something I
can do unthinkingly while I contemplate some aspect or usage
of the code just written; fingers like to stay busy.
Do you change these comments when you afterwards change the code?
My four rules are:
1. At the top of the file there is an explanation WHAT
the program is going to do, which METHOD it uses (references!)
and, not in depth, HOW it is doing it.
2. Every word has a stack comment.
3. At the end of the file there is word which runs a small example,
exercising the code. The output is self-explaining, or it
refers to [1].
4. (optional) Internal words, if any, are marked as such and
preferably hidden. This allows the user to skip such words
in the first reading.
-marcel
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 475 |
Nodes: | 16 (2 / 14) |
Uptime: | 20:13:08 |
Calls: | 9,487 |
Calls today: | 6 |
Files: | 13,617 |
Messages: | 6,121,093 |