SerenityOS / jakt

The Jakt Programming Language

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Mutable types

awesomekling opened this issue · comments

Jakt currently does not track mutability of types. Instead, it awkwardly conflates mutability of bindings with mutability of types.

We should split a type T into T and mut T. This would map to T const and T in the generated C++.

let x = get_some<mut T>() should create an immutable binding to a mut T

mut x = get_some<T>() should create a mutable binding to a T

Mutation method calls should only be allowed on mut T values, not T.

Passing a mut T to a function parameter of type T should be allowed.

There are probably other details that need figuring out.