internally, how to do it:
ASSIGNMENT, as in, Change-my-values-w/o-changing-my-type,
is in the vtable for the object.
When an object becomes constant, its ASSIGNMENT function gets
replaced with
$heres_what_it_gets_replaced_with=sub{
throw "ERROR-ASSIGNMENT-TO-CONSTANT"
};
or something very much like that.
Constanting an array or hash as described in 83 will require an iteration
over the container.
> It is proposed that a new syntax for declaring constants be introduced:
>
> my $PI : constant = 3.1415926;
> my @FIB : constant = (1,1,2,3,5,8,13,21);
> my %ENG_ERRORS : constant = (E_UNDEF=>'undefined', E_FAILED=>'failed');
>
> Constants can be lexically or globally scoped (or any other new scoping
> level yet to be defined).
>
> If an array or hash is marked constant, it cannot be assigned to, and its
> elements can not be assigned to:
>
> @FIB = (1,2,3); # Compile time error
> @FIB[0] = 2; # Compile time error
> %ENG_ERRORS=(); # Compile time error
> %ENG_ERRORS{E_UNDEF=>'No problem'} # Compile time error
>
> To create a reference to a constant use the reference operator:
>
> my $ref_pi = \$PI;
>
> To create a constant reference use a reference operator in the
> declaration:
>
> my $a = 'Nothing to declare';
> my $const_ref : constant = \$a;
>
> Note that this does not make the scalar referenced become constant:
>
> $$const_ref = 'Jewellery'; # No problems
> $const_ref = \4; # Compile time error
>
> =head1 IMPLEMENTATION
>
> Constants should have the same behaviour as the do now. They should be
> inlined, and constant expressions should be calculated at compile time.
>
> =head1 EXTENSIONS
>
> It may be desirable to have a way to remove constness from a value. This
> will not be covered in this RFC--if it is required a separate RFC should
> be written referencing this one.
--
David Nicol 816.235.1187 [EMAIL PROTECTED]
Damian Conway for president