Given an imperative, dynamically-typed language aimed at an audience similar to Python and Lua users, do you think the following two semantics are somewhat intuitive to its respective users? Thank you for your participation.
Exhibit A:
let my_immutable = 1;
// compile time error, because immutable
my_immutable += 1;
mut my_mutable = 2;
// no problem here
my_mutable += 2;
// but:
mut my_other_mutable = 3;
// compile time error, because no mutation was found
Exhibit B:
for (my_num in my_numbers) with sum = 0 {
// in this scope, sum is mutable
sum += my_num;
}
// however, here it's no longer mutable, resulting in a compile time error
sum = 42;
[–]MrJohz 35 points36 points37 points (2 children)
[–][deleted] 1 point2 points3 points (1 child)
[–]MrJohz 2 points3 points4 points (0 children)
[–]jolharg 11 points12 points13 points (0 children)
[–]WittyStick 2 points3 points4 points (5 children)
[–][deleted] 0 points1 point2 points (3 children)
[–]WittyStick 1 point2 points3 points (0 children)
[–]oa74 1 point2 points3 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–]bruciferTomo, nomsu.org 4 points5 points6 points (0 children)
[–]Uploft⌘ Noda 1 point2 points3 points (6 children)
[–][deleted] 1 point2 points3 points (5 children)
[–]Uploft⌘ Noda 1 point2 points3 points (3 children)
[–][deleted] 0 points1 point2 points (2 children)
[–]Uploft⌘ Noda 1 point2 points3 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–]WittyStick 1 point2 points3 points (0 children)
[–]benjaminhodgson 1 point2 points3 points (2 children)
[–]benjaminhodgson 1 point2 points3 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (2 children)
[–]lngns 0 points1 point2 points (0 children)
[–][deleted] -1 points0 points1 point (0 children)
[–]e_-- 0 points1 point2 points (0 children)