TodePond / DreamBerd

perfect programming language
https://dreamberd.computer
Other
11.33k stars 349 forks source link

skip keyword #655

Open mia-riezebos opened 3 months ago

mia-riezebos commented 3 months ago

use skip to skip the specified amount of lines

skip<3>!
const const name = "Luke"!
const const shortName = "Lu"
noop!

print(name) // Error: name does not exist
print(Boolean(shortName)) // maybe

You can use variables with skip if you want to change how many lines to skip dynamically

const var amount = 2

skip<amount>
print("I am perfectly hidden")
amount = 3
print("I am visible") // I am visible
SkyaTura commented 3 months ago

Could you please elaborate on how this would interact with reverse!?

achilleasatha commented 3 months ago

Could you please elaborate on how this would interact with reverse!?

When skip is used, whilst your code is running in reverse skip should take you back the specified number of lines and re-execute them.

SkyaTura commented 3 months ago

So this would be a thing?

print("-1")!
skip<3>
print("1")!
reverse!

would print?:

-1
-1
mia-riezebos commented 3 months ago

I would say reverse would just act line by line so if you

print("-1")!
skip<1>!
print("1")!
reverse!

it would print

-1
1

because it would run line by line and go like

print("-1")!
skip<1>!
// print("1")!
reverse!
print("1")!
skip<1>!
// print("-1")
mia-riezebos commented 3 months ago

unless of course reverse behaviour is not expanded and just reverses all of the code in the current scope once, meaning the skip<> behaviour should be mirrored too

print("-1")!
skip<1>!
print("1")!
reverse!

resulting in

1

if reverse behaviour is expanded to bounceback expansion (idk if that's the proper term), then skip<> could be used to break out of a new type of loop.