Comment by rvba

13 days ago

> In herd, everything is immutable unless declared with var

So basucally everything is var?

I'm not sure if I understand the question?

There are two ways to define a variable binding:

    x = 1; // declares x as immutable
    var y = 2; // declares y as mutable

The "default" behaviour (if no keyword is used) is to define a new immutable variable.

  • I'm asking if the reality wouldn't be that "everything" is set as mutable by default and the non mutable part is ignored.

    • In the programs I write probably about 80-90% of variables are immutable, and I think this probably corresponds to most other code. Except in certain domains and programming styles, not that much stuff tends to need mutability.

      This is why the syntax "encourages" immutability by making it the easiest option (similar to e.g. Rust, F#). On the other hand, if it was an extra keyword nobody would use it (e.g. like Java).