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

Add constant variables to E2 #2769

Merged
merged 1 commit into from
Oct 4, 2023
Merged

Add constant variables to E2 #2769

merged 1 commit into from
Oct 4, 2023

Conversation

Vurv78
Copy link
Contributor

@Vurv78 Vurv78 commented Oct 1, 2023

Allows creating immutable variables with const keyword.

Brings the language a little closer to typescript and a lot of people may just prefer this over lua's odd local keyword.

const X = 5

const X = 2 # Compile error
local X = 2 # Compile error
X = 2 # Compile error

print(X)

Potentially inputs could be marked as const with this too (since mutating them does nothing)

Also prevents you from redeclaring local variables in a scope, which is allowed for backwards compat

local X = 5
local X = 5 # Allowed, albeit with a warning now
const X = 5
const X = 5 # Compile error

@Fasteroid
Copy link
Contributor

yes please~

@Denneisk
Copy link
Member

Denneisk commented Oct 1, 2023

I see AOT optimization in your future.

@Vurv78
Copy link
Contributor Author

Vurv78 commented Oct 1, 2023

Nah this is more of a cosmetic change if anything, I could very well just treat local X = 5 the same as const X = 5 assuming it's never mutated.

Thinking of adding let too but that's not really necessary right now. At least const adds something in that you can be sure a variable is never mutated

@Fasteroid
Copy link
Contributor

Fasteroid commented Oct 3, 2023

Nah this is more of a cosmetic change if anything

balls, so no const @persist?

@Vurv78 Vurv78 merged commit d7c73b0 into wiremod:master Oct 4, 2023
1 check failed
@Vurv78 Vurv78 deleted the constants branch October 4, 2023 17:40
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.

4 participants