On Fri, Aug 12, 2005 at 04:16:52PM +0200, TSa wrote: : HaloO, : : Autrijus Tang wrote: : >Or do you think that people should really write ::= for constants? : : For me that is one option if I want the parser to recognize the : bareword pi and attach the same meaning as the literal 3. : We have at least : : my ::pi ::= 3; : my enum <pi( 3)>; # I hope the whitespace doesn't hurt : my macro pi { 3 }; : my &pi = { 3 };
Maybe it's now constant num pi = 3; : BTW, are all these competing for the same name slot or can : some or all exist in parallel? Can they if the type is the : same but not for : : my ::pi ::= 1; That's in the type namespace, which is to say, package/module/class namespace. : my enum <pi( 2)>; Whether that ends up in type namespace or function namespace depends on how far we stretch the subtype metaphor. The Apocalypse has it as a subtype. : my macro pi { 3 }; : my &pi = { 4 }; Those both live in the function namespace, as would the new constant declarator if we include the sigilless form above . : The form : : my $pi is constant = 3; : : to me bears the disadvantage, that it doesn't look like a : constant at the use site : : $yi = $pi++ + $xi; # error can't modify $pi : : where I would oblige me to know more about bare pi then $pi. : The latter obviously is a variable. The return value of pi : is not so obvious. Yes, and there's little need to require the $ anymore for interpolation since you can always say {pi} for that. : In an interface definition however : : sub foo( $pi is constant ) {...} : : tells the prospective caller that her arguments are : not messed about with. What the inside does with the : local copy is at least not of interest to the caller. : But to the optimizer. Thus Perl6 also has the form : : sub foo( $pi is copy ) {...} : : right? The crux is what shall : : sub foo( $pi ) {...} : : default to. With a relatively cheap COW backend I would : prefer 'is copy'. That's something we could relax later if COW becomes ubiquitous, but the conservative way forward is to disallow writes in the function body for now. But you're right that the caller doesn't care which way that's done. : Enjoy my silence for the next two weeks. : I'll be offline at least that long. Have the appropriate amount of fun. :-) Larry