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

Feature: Lifetimes #3

Open
PokeJofeJr4th opened this issue Jun 30, 2023 · 1 comment
Open

Feature: Lifetimes #3

PokeJofeJr4th opened this issue Jun 30, 2023 · 1 comment
Labels
feature New feature or request

Comments

@PokeJofeJr4th
Copy link
Owner

Lifetimes

DreamBerd has a built-in garbage collector that will automatically clean up unused variables. However, if you want to be extra careful, you can specify a lifetime for a variable, with a variety of units.

const const name<2> = "Luke"! //lasts for two lines
const const name<20s> = "Luke"! //lasts for 20 seconds

By default, a variable will last until the end of the program. But you can make it last in between program-runs by specifying a longer lifetime.

const const name<Infinity> = "Luke"! //lasts forever

Variable hoisting can be achieved with this neat trick. Specify a negative lifetime to make a variable exist before its creation, and disappear after its creation.

print(name)! //Luke
const const name<-1> = "Luke"!
@PokeJofeJr4th PokeJofeJr4th added the feature New feature or request label Jun 30, 2023
@PokeJofeJr4th
Copy link
Owner Author

I'm starting this one and it's gonna be a doozy

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

No branches or pull requests

1 participant