Revision 28150

Date:
2009/08/31 23:42:06
Author:
lwall
Revision Log:
[S03] steal ::= for readonly binding ala sigs
Files:

Legend:

 
Added
 
Removed
 
Modified
  • docs/Perl6/Spec/S03-operators.pod

     
    14 14
    15 15 Created: 8 Mar 2004
    16 16
    17 Last Modified: 29 Aug 2009
    18 Version: 170
    17 Last Modified: 31 Aug 2009
    18 Version: 171
    19 19
    20 20 =head1 Overview
    21 21
     
    1465 1465
    1466 1466 =item *
    1467 1467
    1468 C<< infix:<::=> >>, compile-time binding
    1468 C<< infix:<::=> >>, bind and make readonly
    1469 1469
    1470 1470 $signature ::= $capture
    1471 1471
    1472 This does the same as C<:=> except it does it at compile time. (This implies
    1473 that the expression on the right is also evaluated at compile time; it does
    1474 not bind a lazy thunk.)
    1472 This does the same as C<:=>, then marks any destination parameters as
    1473 readonly (unless the individual parameter overrides this with either
    1474 the C<rw> trait or the C<copy> trait). It's particularly useful
    1475 for establishing readonly context variables for a dynamic scope:
    1475 1476
    1477 {
    1478 my $*OUT ::= open($file, :w) || die $!;
    1479 doit(); # runs with redirected stdout
    1480 }
    1481 doit(); # runs with original stdout
    1482
    1483 If C<doit> wants to change C<$*OUT>, it must declare its own
    1484 contextual variable. It may not simply assign to C<$*OUT>.
    1485
    1486 Note that the semantics of C<::=> are virtually identical to
    1487 the normal binding of arguments to formal subroutine parameters
    1488 (which also default to readonly).
    1489
    1476 1490 =item *
    1477 1491
    1478 1492 C<< infix:{'=>'} >>, Pair constructor