On Fri, Aug 12, 2005 at 01:43:43AM +0800, Autrijus Tang wrote: : On Wed, Aug 10, 2005 at 12:41:17PM -0700, Larry Wall wrote: : > : If yes, what does it desugar to? : > : : > : my $pi is constant := 3; : > : my $pi is constant ::= 3; : > : > In this case it desugars to : > : > my $pi is constant = 3; : > : > :-) : : However, I wonder if the intention was to replace the Perl 5 form of: : : use constant PI => 3; : : Which is a binding that happens at compile time. It'd be somewhat : strange if this dies with undef -- or even 'Str': : : my Str $x is constant = 'foo'; : BEGIN { die $x }; : : Or do you think that people should really write ::= for constants?
Hmm, well, we do need some form that is only temporarily constant for this time through the elaboration and subsequent code. That is the sense of "constant" we're applying formal parameters, after all. So either we have to bifurcate the concept into "temporarily constant" and "permanently constant", or we force people to distinguish with ::= (or "is constant('foo')"), or we make some representations about the requirement for the compiler to optimize the = form to: my Str $x is constant('foo'); if the assigned value is "static" (much as we require the tailcall optimization these days). So this would be another instance of making the default semantics late binding, but optimized to earlier binding in cases where it makes no semantic difference other than a difference in run-time efficiency. Making this determination is pretty much equivalent to constant folding. Larry