The following warnings occurred:
Warning [2] count(): Parameter must be an array or an object that implements Countable - Line: 795 - File: showthread.php PHP 7.4.33 (FreeBSD)
File Line Function
/showthread.php 795 errorHandler->error





Post Reply 
RPL comment syntax
08-26-2023, 11:49 PM
Post: #1
RPL comment syntax
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:

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?
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RPL comment syntax - c3d - 08-26-2023 11:49 PM
RE: RPL comment syntax - Raymond Del Tondo - 08-27-2023, 01:03 AM
RE: RPL comment syntax - rprosperi - 08-27-2023, 01:29 AM
RE: RPL comment syntax - Claudio L. - 08-27-2023, 03:56 AM
RE: RPL comment syntax - c3d - 08-27-2023, 06:45 AM
RE: RPL comment syntax - rprosperi - 08-27-2023, 12:08 PM
RE: RPL comment syntax - John Keith - 08-27-2023, 04:34 PM
RE: RPL comment syntax - Gilles - 08-27-2023, 08:34 AM
RE: RPL comment syntax - c3d - 08-27-2023, 11:05 AM
RE: RPL comment syntax - John Keith - 08-27-2023, 04:19 PM
RE: RPL comment syntax - Helix - 08-27-2023, 11:00 AM
RE: RPL comment syntax - BruceH - 08-27-2023, 05:13 PM



User(s) browsing this thread: 2 Guest(s)