enact-lang/enact

Improve const semantics

Dandigit opened this issue · 1 comments

Currently, when defining a variable with const, all that is ensured is that the variable itself is not reassigned. Properties of the variable can still be reassigned and changed - I'd like this not to be the case.

Here's an example of what I'm talking about:

const arr = [1, 2, 3, 4, 5]

// You can't do this:
arr = [1, 2]

// But you can do this:
arr[0] = 2
// This shouldn't be allowed!

// Same applies for structs:
struct Person:
    name string
    age int
end

const jim = Person("Jim", 29)

// You can't do this:
jim = Person("Sam", 45)

// But you can do this:
jim.name = "Sam"
// And you shouldn't be able to!

This will no longer be implemented, see #73. Both the syntax and semantics of the language will change completely.