Technohacker / spaghetti

A programming language that uses goto extensively
MIT License
11 stars 0 forks source link

Use line numbers instead of labels #1

Open bwalter opened 5 years ago

bwalter commented 5 years ago

When writing spaghetti code, I am always annoyed by the usage of labels. It adds a lot of overhead and would not be needed if the lines were numbered.

For standard labels, reserved/negative line number could be used.

Advantages:

To allow line insertions, it is recommended to use a step of 10 (10, 20, 30 instead of 1, 2, 3).

Example (based on factorial.spgh).

Instead of:

main:
    ; Input
    5 "num"
    goto store

    ; Return label
    "after" "ret"
    goto store

    ; Set factorial to 1
    1 "factorial"
    goto store

    goto fact

fact:
    ; Get the input
    "num"
    goto retrieve

use:

  7: ; Input
 10: 5 "num"
 20: goto -2507  ; store
 30:
 40: ; Return label
 50: "after" "ret"
 60: goto -2507  ; store
 75:
 80: ; Set factorial to 1
 90: 1 "factorial"
100: goto -2507  ; store
110:
120: goto 200

200: ; Get the input
210: "num"
220: goto -2184  ; retrieve
Technohacker commented 5 years ago

Oh sweet Jesus, Just when I thought the language couldn't get any worse :joy: I don't maintain spaghetti too much but I could try adding this in someday xD

razetime commented 5 years ago

This method makes a lot more sense than the current syntax spaghetti supports. However, it would be best to keep the current label system for beginner spaghetti coders, and add this alongside the existing system.