Chaim Frenkel wrote:
> A nice way of making a value read-only is lovely. And let it be a
> runtime error to modify it.
>
> The caller can easily do a &foo eval{$const_item} to remove the
> read-only attribute.
>
> Hmm, perhaps we should rename the attribute
> :read-only
>
Can't we make a value 'truely constant', as inlined subs do now? It would be
nice to declare data 'truely constant' and 'never aliased' to enable
appropriate optimisations (these are two separate attributes, BTW).
Modifying a constant value using eval should give the same errors as
modifying a literal--and I would have thought this would be
straightforwards, if the constant is just replaced with its value at compile
time. Aliasing a 'never aliased' value should also provide a meaningful
error.

Currently, of course, another problem with constants as inlined subs is that
the errors are horrible:

  use constant AA=>6;
  AA = 5;
  # Can't modify non-lvalue subroutine call in scalar assignment

Ick!


Reply via email to