ammarbinfaisal / sahl

a programming language with channels and coroutines/threads
MIT License
9 stars 1 forks source link

`let mut` for mutable values #26

Open ammarbinfaisal opened 1 year ago

ammarbinfaisal commented 1 year ago

also mut would be used in function prototype to indicate whether the value is mutable or not. if it is primitive then the copy passed to the function would be mutated. if it is a reference then the original object would be mutated.

Example:

fun mutate(mp: mut map<int, bool>) {
    mp[1] = true
}

fun main() {
    let m = make(map<int, bool>)
    mutate(m)
    print(mp[1]) // true
}