Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposal: Labelling lines #715

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

tech-meppem
Copy link

Obviously no goto as that would allow loops.

@guigui0246
Copy link

guigui0246 commented Jul 16, 2024

Defining labels should work one of the 2 following ways instead:

Original thoughs:

var var score = 1!
:increase_score: = score = score + 3! // sets the next line
increase_score: score = score + 1! // +3 for the label and +1 for the line (same as "score = score + 3! score = score + 1!" because you change "increase_score:" by it's value)
print(score)! // 5

Better way I though of in the toilets:

var var score = 1!
:increase_score: = score = score + 3! // sets the next line
increase_score: score = score + 1! // 1 = 3 because of previous line and +3 to score
print(score)! // 4
print(1)? // 3
var var value!
increase_score: score = value! // value = score + 3
print(score) // 7
print(value) // 10
increase_score: value + 2 // value = score = score and 2 = 3! (edit: don't forget there's an ! in 2 now so it cuts the line between instructions)
print(value)! // true
print(2)? // 3

@tech-meppem
Copy link
Author

tech-meppem commented Jul 17, 2024

Original thoughs:

var var score = 1!
:increase_score: = score = score + 3! // sets the next line
increase_score: score = score + 1! // +3 for the label and +1 for the line (same as "score = score + 3! score = score + 1!" because you change "increase_score:" by it's value)
print(score)! // 5

I think that would be better achieved with += instead:

:increase_score: += score = score + 3!
increase_score: score = score + 1! // is actually "score = score + 1! score = score + 3!"

You could then use subtract to "invert" the line:

:increase_score: -= score = score + 3!
increase_score: score = score + 1! // is actually "score = score +1! score = score - 3!"

Another functionality we could implement: Shifting.

:increase_score: << 3! //moves line execution up three lines
:increase_score: >> 2! //moves line execution down two lines

:increase_score: <<< 3! //moves label up three lines
:increase_score: >>> 2! //moves label down two lines

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants