←back to thread

498 points azhenley | 1 comments | | HN request time: 0s | source
Show context
Razengan ◴[] No.45770236[source]
If designing your hypothetical ideal language, what are some intuitive/cute keywords you would choose for mutables/immutables?

`let` is so 2020. `const` is too long. `static` makes me fall asleep at the keyboard. `con` sounds bad. How about

`law`?

    law pi = 3.142 (heh typing on Mac autocompleted this)

    law c = 29979245

    law law = "Dredd"
or `set` or `once` or `make`?
replies(4): >>45770286 #>>45771270 #>>45771607 #>>45779782 #
tomaytotomato ◴[] No.45770286[source]
There was a proposal in Java a few years back to introduce "val".

I think it never gained traction but it would have been nice to have this in Java

    val firstName = "Bob";
    val lastName = "Tables";
    var fullName = "";

    fullName = firstName + " " + lastName;
replies(2): >>45770383 #>>45770702 #
1. mcdeltat ◴[] No.45770383[source]
Wouldn't this "val" be the same as "final"?

Also related, it annoys me that Java has final but otherwise poor/leaky support for immutability. You can mark something final but most Java code (and a lot of the standard library) uses mutable objects so the final does basically nothing... C++ "const" desparately needs to spread to other languages.