On Wed, Aug 17, 2005 at 01:56:35PM +1000, Adam Kennedy wrote:
: 
: >: If not a special form, should this work? 
: >: 
: >:     my $pi is constant;
: >:     $pi = 3;
: >
: >That could be made to work by defining constant to mean you can assign
: >to it if it's undefined.  But then it gets a little harder to reason
: >about it if $pi can later become undefined.  I suppose we could
: >disallow undefine($pi) though.
: 
: Which would basically throw away compile-time optimizations relating to 
: constants wouldn't it?

You could still reason about it if you can determine what the initial
value is going to be.  But certainly that's not a guarantee, which
is one of the reasons we're now calling this write/bind-once behavior
"readonly" and moving true constants to a separate declarator:

    my $pi is readonly;
    $pi = 3;

vs

    constant $pi = 3;

or

    constant Num pi = 3;

or if you like, even

    constant π = 3;

Larry

Reply via email to