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 };

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;
  my enum <pi(    2)>;
  my macro pi   { 3 };
  my      &pi = { 4 };


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.


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'.


Enjoy my silence for the next two weeks.
I'll be offline at least that long.
--
$TSa.greeting := "HaloO"; # mind the echo!

Reply via email to