08-26-2023, 11:49 PM
I am in the process of implementing comments for DB48X, and I am wondering about the best way to deal with them.
There seems to be a wide consensus that comments in RPL begin with @ and end with a newline. This is exemplified with code found on the Wikipedia page about RPL, which has examples like this:
Notice that the comments are aligned on the right. That also seems to be a rather common style for RPL comments.
Now, I see several ways to approach comments on DB48X:
1/ Parse them, but ignore them. In other words, the comments are not kept in the object, and if you edit, you won't see them. That makes sense if you edit your files on a PC to be consumed by the calculator.
2/ To have a "comment" object type, which preserves a comment in the source code, and has no effect during execution. That seems more useful on a calculator, but has the problem that RPL compiles objects, so you need a nice way to render comments.
That's where the style above is a bit problematic. While it looks nice on a PC screen, it's next to unusable on the calculator screen, for two reasons:
a) being on the right, they are rarely visible along with the code.
b) keeping the comments nicely aligned adds a lot of complexity to the editor code.
So I would like to know how you feel about the following approaches
1) Have two types of comments, one being removed at parse time, the other being preserved. I'm thinking that comments beginning with @ could be preserved and comments beginning with $ or maybe @@ would be eliminated.
2) Change the "standard" style for RPL programs where comments would be on a line on their own, aligned with the code.
This is what my code decompiler produces at the moment:
Does that sound like an acceptable trade-off?
There seems to be a wide consensus that comments in RPL begin with @ and end with a newline. This is exemplified with code found on the Wikipedia page about RPL, which has examples like this:
Code:
«
0 @ Start with zero on the stack
1 10 @ Loop from 1 to 10
FOR I @ "I" is the local variable
I + @ Add "I" to the running total
NEXT @ Repeat...
»
Notice that the comments are aligned on the right. That also seems to be a rather common style for RPL comments.
Now, I see several ways to approach comments on DB48X:
1/ Parse them, but ignore them. In other words, the comments are not kept in the object, and if you edit, you won't see them. That makes sense if you edit your files on a PC to be consumed by the calculator.
2/ To have a "comment" object type, which preserves a comment in the source code, and has no effect during execution. That seems more useful on a calculator, but has the problem that RPL compiles objects, so you need a nice way to render comments.
That's where the style above is a bit problematic. While it looks nice on a PC screen, it's next to unusable on the calculator screen, for two reasons:
a) being on the right, they are rarely visible along with the code.
b) keeping the comments nicely aligned adds a lot of complexity to the editor code.
So I would like to know how you feel about the following approaches
1) Have two types of comments, one being removed at parse time, the other being preserved. I'm thinking that comments beginning with @ could be preserved and comments beginning with $ or maybe @@ would be eliminated.
2) Change the "standard" style for RPL programs where comments would be on a line on their own, aligned with the code.
This is what my code decompiler produces at the moment:
Code:
«
→ Size
«
Degrees ClearLCD 0 360000
for i
@ Set foreground
#1111111111111111 i 16 mod × Foreground
@ Build starting point
{}
@ X coordinate
i sin Size × +
@ Y coordinate
i cos Size × +
@ Build end point
{}
@ X coordinate
i 2.3 × sin Size × +
@ Y coordinate
i 2.5 × cos Size × +
@ Draw the line and wait for 1ms
DrawLine 0.001 Wait
next
0 Wait Drop
»
»
Does that sound like an acceptable trade-off?