> # >    my $foo is const = 0 is true;
   > # >
   > # > $foo has the property const, while the value 0 in $foo has
   > # > the property true.
   > #
   > # So, if I do
   > #
   > # my $foo is constant = new Counter(0);
   > # $foo->increment # OK
   > 
   > I think so.

Yep. Except the property name is likely to just be C<const>.


   > # my $bar = new Counter(0) is constant;
   > # $bar->increment; #error
   > 
   > Maybe.  I think that would depend on the Counter class's implementation

The "constant" property is applied to the particular reference to the
object that was returned by C<new> and stored in $bar (*not* to the object
itself!) Hence, the C<Counter::increment> method would have to be
something like the following, in order to respect it:

        sub increment ($self) {
                croak "Can't increment constant Counter" if $self.constant;
        }


   > # However, if I do
   > #
   > # %foo is constant = (a=>1, b=>$foo);
   > #
   > # are only the keys contant; or both the keys and values.
   > 
   > Keys and values, I imagine.

Probably.


Damian

Reply via email to