Greg Boug wrote:
> Apologies if these comments have already been noted...
>
> > 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).
>
> Just curious about how the use of 'my' and 'local' would be brought into
> this. Assume for the moment you don't use strict vars in a script (why
> you wouldn't, I don't know, but some people don't...) Would that
> mean that:
>
> $notusingstrict : constant = 1.2345;
>
> would be legal? Personally, I would prefer to enfore the use of
> strict vars for constants, as it is then obvious as to the scope...
>
Good question. I haven't tackled this in RFC 83, because it is a more
general question about attribute syntax. We don't really have a good
attribute syntax RFC yet, although Nate threw up some ideas a couple of days
ago. Is someone interested in whipping up an RFC that combines Nate's
suggestions with clarification of issues such as this?
> But then again, I'd also prefer use strict to be the default... ;-)
>
> Also, presumably the following:
>
> my $notconstant = 1.2345;
> my $const : constant = $notconstant;
>
> would cause $const == 1.2345 and remain constant at that value...
>
Yes, this doesn't effect $notconstant in any way. It simply creates a new
constant with the value of 1.2345. Constants such as this can't be inlined
at compile time, so instead they would be implemented as scalars with a
constant flag.