Daniel Ruoso daniel-at-ruoso.com |Perl 6| wrote:

For an Object to be a value, it means that if you build an object with
the same "value", it will be seen as the same "value" that some other
object with this value.
Perl 6 formalizes this by defining a "value type" as one whose identity is keyed to its value. Multiple physical copies in memory (or copies without memory like numbers in registers) will test as identity-equvilent.

A sane requirement for this to happen is that "value" objects are
read-only, which is something pretty straight-forward.

The thing is that, for a "value" object, there isn't any difference in

  my $a := 3;


  my $a := 3.clone();

Because the number '3' is a value, and you usually doesn't expect a
value to change its value at a distance, that's why Int is Immutable.

Yes, with immutable objects you don't have to clone it. Multiple copies can be shared.

By making "value types" as described above also immutable, it formally removes all distinction between reference assignment and value assignment.

Reply via email to