Changeset 7752

Show
Ignore:
Timestamp:
10/27/05 21:19:10 (3 years ago)
Author:
iblech
Message:

+$arg changed to :$arg, per Larry
(http://www.nntp.perl.org/group/perl.perl6.language/23820).
* examples, t, ext, docs, perl5, src/perl6: Changed +$arg to :$arg (and

related) -- I searched using egrep -r '\+\+?\s*[$@%]', hopefully I've found
all occurances...

* Pugs.Lexer: ":Foo" is not a valid type.
* Pugs.Parser: Parse :$arg, +:$arg etc. (but not :foo($bar) yet, as this

requires changes to the definition of VCode).

* Pugs.Parser: Adjustments to the rule which parses the

invocant-list-delimeter-colon --

method foo (: $a) # positional $a, $a is not an inv param
method foo (:$a) # named $a

Note that I had to use lookAhead and try...

* Pugs.AST.Internals: Minor adjustment WRT the Pugs.Parser change.

Files:
35 modified

Legend:

Unmodified
Added
Removed
  • docs/AES/S29draft.pod

    r6918 r7752  
    120120=item exp 
    121121 
    122  multi sub  Num::exp (  Num  $exponent             : Num +$base) returns Num 
    123  multi sub Math::Basic::exp (: Num ?$exponent = $CALLER::_, Num +$base) returns Num 
     122 multi sub  Num::exp (  Num  $exponent             : Num :$base) returns Num 
     123 multi sub Math::Basic::exp (: Num ?$exponent = $CALLER::_, Num :$base) returns Num 
    124124 
    125125Performs similar to C<$base ** $exponent>. C<$base> defaults to the 
     
    129129=item log 
    130130 
    131  multi sub  Num::log (  Num  $x             : Num +$base) returns Num 
    132  multi sub Math::Basic::log (: Num ?$x = $CALLER::_, Num +$base) returns Num 
     131 multi sub  Num::log (  Num  $x             : Num :$base) returns Num 
     132 multi sub Math::Basic::log (: Num ?$x = $CALLER::_, Num :$base) returns Num 
    133133 
    134134Logarithm of base C<$base>, default Natural. Calling with C<$x == 0> is an 
     
    186186=item I<Standard Trig Functions> 
    187187 
    188  multi sub Num::func (  Num  $x             : +$base) returns Num 
    189  multi sub Math::Trig::func (: Num ?$x = $CALLER::_, +$base) returns Num 
     188 multi sub Num::func (  Num  $x             : :$base) returns Num 
     189 multi sub Math::Trig::func (: Num ?$x = $CALLER::_, :$base) returns Num 
    190190 
    191191where I<func> is one of: 
     
    209209=item atan 
    210210 
    211  multi sub Math::Trig::atan (Num $y, Num $x : Num +$base) returns Num 
     211 multi sub Math::Trig::atan (Num $y, Num $x : Num :$base) returns Num 
    212212 
    213213This second form of C<atan> computes the arctangent of $y/$x, and takes 
     
    430430 multi sub Array::sort(                 @values is rw, 
    431431                                              *&by 
    432                               :           Bit +$inplace 
     432                              :           Bit :$inplace 
    433433                             ) returns Array 
    434434 
    435435 multi sub Array::sort(                 @values is rw, 
    436436                                SortCriterion  @by 
    437                               :           Bit +$inplace 
     437                              :           Bit :$inplace 
    438438                             ) returns Array 
    439439 
    440440 multi sub Array::sort(                 @values is rw 
    441                               : SortCriterion +$by = &infix:<cmp>, 
    442                                           Bit +$inplace 
     441                              : SortCriterion :$by = &infix:<cmp>, 
     442                                          Bit :$inplace 
    443443                             ) returns Array 
    444444 
     
    496496=item zip 
    497497 
    498  multi sub Lists::zip (: Array *@lists, Bit +$shortest) returns Lazy { 
     498 multi sub Lists::zip (: Array *@lists, Bit :$shortest) returns Lazy { 
    499499   gather { 
    500500     while $shortest ?? all (@lists) !! any(@lists) { 
     
    715715=item eval  
    716716  
    717  multi sub Control::Basic::eval (: Str $code = $CALLER::_, Str +$lang = 'Perl6') 
     717 multi sub Control::Basic::eval (: Str $code = $CALLER::_, Str :$lang = 'Perl6') 
    718718 
    719719Execute C<$code> as if it were code written in C<$lang>. C<Perl6> is the 
     
    726726=item evalfile 
    727727 
    728  multi sub Control::Basic::evalfile (Str $filename : Str +$lang = 'Perl6') 
     728 multi sub Control::Basic::evalfile (Str $filename : Str :$lang = 'Perl6') 
    729729 
    730730Behaves like, and replaces Perl 5 C<do EXPR>, with optional C<$lang> 
  • docs/quickref/namespace

    r7136 r7752  
    168168    sub foo ($param) { $param =:= $a } 
    169169 
    170     my ($foo, ?$blarb, +$baz) := some_sub(); 
     170    my ($foo, ?$blarb, :$baz) := some_sub(); 
    171171 
    172172    # ::= is binding at compile-time. 
  • examples/cookbook/10subroutines/10-01arguments.p6

    r3174 r7752  
    4848optional('this', 'that'); 
    4949 
    50 sub named_params ($first, +$second, +$third) { 
     50sub named_params ($first, :$second, :$third) { 
    5151    say $first, $second, $third; 
    5252} 
  • examples/nested_loops/coroutine.p6

    r6365 r7752  
    99my @loops = ([1..3], ['a'..'e'], ['foo', 'bar']); 
    1010 
    11 sub NestedLoop (++@loop, +$only_when, +$code) { 
     11sub NestedLoop (+:@loop, :$only_when, :$code) { 
    1212    my &iter = NL2(loop => @loop); 
    1313 
     
    2525} 
    2626 
    27 sub NL2 (++@loop) { 
     27sub NL2 (+:@loop) { 
    2828    coro { 
    2929        given (@loop.elems) { 
  • examples/nested_loops/iterative.p6

    r4374 r7752  
    88my @loops = ([1..3], ['a'..'e'], ['foo', 'bar']); 
    99 
    10 sub NestedLoop (++@loop, +$OnlyWhen, +$code) returns Ref{ 
     10sub NestedLoop (+:@loop, :$OnlyWhen, :$code) returns Ref{ 
    1111    my @pos = 0 xx (@loop.elems - 1), -1; 
    1212    return sub { 
  • examples/obfu/l33t.p6

    r7548 r7752  
    117117}; 
    118118 
    119 method mem($target is rw, ++$wrap, ?$down) { 
     119method mem($target is rw, +:$wrap, ?$down) { 
    120120    ./IIP; 
    121121    $target += (@.mem[$.ip] + 1) * ($down ?? -1 !! 1); 
  • examples/tutorial_gen/tut.p6

    r6851 r7752  
    121121 
    122122 
    123 sub get_output ( Str $tut_fp, +$each_line = 0 ) { 
     123sub get_output ( Str $tut_fp, :$each_line = 0 ) { 
    124124    my $file_t = slurp $tut_fp || die "Slurp failed '$tut_fp'\n"; 
    125125    my @parts = ( $each_line ) ?? split( "\n", $file_t ) !! split( "\n\n", $file_t ); 
     
    180180    @parts, @out_parts,  
    181181    Str $prev_tut_fn, Str $tut_fn, Str $next_tut_fn,  
    182     Str $out_dir, Str +$suffix  
     182    Str $out_dir, Str :$suffix  
    183183) { 
    184184    use HTML::Entities; 
  • examples/vmethods/time.p6

    r4677 r7752  
    6363our &century:=&centuries; 
    6464 
    65 multi sub ago (Int $value: Int +$time = time()) { 
     65multi sub ago (Int $value: Int :$time = time()) { 
    6666    $time - $value; 
    6767} 
     
    6969our &until:=&ago; 
    7070 
    71 multi sub since (Int $value: Int +$time = time()) { 
     71multi sub since (Int $value: Int :$time = time()) { 
    7272    $time + $value; 
    7373} 
  • ext/CGI/lib/CGI.pm

    r6852 r7752  
    5858    Str ?$status = '200 OK', 
    5959    Str ?$charset, 
    60     Str +$cookies, 
    61     Str +$target, 
    62     +$expires, 
    63     Bool +$nph, 
     60    Str :$cookies, 
     61    Str :$target, 
     62    :$expires, 
     63    Bool :$nph, 
    6464    *%extra 
    6565) returns Str is export { 
     
    106106    Str ?$target, 
    107107    Str ?$status = "302 Found", 
    108     Str +$cookie, 
    109     Bool +$nph, 
     108    Str :$cookie, 
     109    Bool :$nph, 
    110110    *%extra 
    111111) returns Str is export { 
     
    241241} 
    242242 
    243 sub escapeHTML (Str $string, Bool +$newlines) returns Str is export { 
     243sub escapeHTML (Str $string, Bool :$newlines) returns Str is export { 
    244244    # XXX check for $self.escape == 0 
    245245    #unless ($self.escape != 0) { return $toencode; } 
     
    377377=over 4 
    378378 
    379 =item B<header (+$status = '200 OK', +$content_type = 'text/html', +$charset, +$location) returns Str> 
     379=item B<header (:$status = '200 OK', :$content_type = 'text/html', :$charset, :$location) returns Str> 
    380380 
    381381=item B<redirect (Str $location) returns Str> 
  • ext/DateTime/lib/Date.pm

    r6852 r7752  
    2929} 
    3030 
    31 multi submethod BUILD (Int|Real +$epoch) returns Date { 
     31multi submethod BUILD (Int|Real :$epoch) returns Date { 
    3232    $epoch = int $epoch; 
    3333 
     
    5757 
    5858# day as Str where { rx:i/^last$/ } 
    59 multi submethod BUILD (Int +$year, Int +$month = 1, Int|Str +$day is copy = 1) returns Date { 
     59multi submethod BUILD (Int :$year, Int :$month = 1, Int|Str :$day is copy = 1) returns Date { 
    6060    if $day ~~ rx:perl5<i>/^last$/ { 
    6161        my @lengths := _is_leap_year($year) ?? @LeapYearMonthLengths !! @MonthLengths; 
  • ext/FA-DFA/lib/FA/DFA.pm

    r7458 r7752  
    66has bool $.final; 
    77 
    8 multi method addarc(Str $trigger,+$node = FA::DFA::Node.new --> FA::DFA::Node) { 
     8multi method addarc(Str $trigger,:$node = FA::DFA::Node.new --> FA::DFA::Node) { 
    99  %.arc{$trigger} = $node; 
    1010  $node; 
  • ext/File-Find/lib/File/Find.pm

    r5284 r7752  
    1313submethod BUILD { $.debug = 0 } 
    1414 
    15 method find ( $self: +@dirs, +$wanted_dir, +$wanted_file ) { 
     15method find ( $self: :@dirs, :$wanted_dir, :$wanted_file ) { 
    1616    my @start    = @dirs        || @{$.dirs}; 
    1717    my $wdir_cb  = $wanted_dir  || $.wanted_dir  || sub { 1 }; 
  • ext/HTTP-Server-Simple/lib/HTTP/Server/Simple.pm

    r5284 r7752  
    77has IO  $.remote; 
    88 
    9 submethod BUILD ( +$port ) { 
     9submethod BUILD ( :$port ) { 
    1010    $.port = $port || 8080; 
    1111} 
  • ext/Rosetta-Incubator/lib/Locale/KeyedText.pm

    r7748 r7752  
    3636########################################################################### 
    3737 
    38 submethod BUILD (Str +$msg_key is required, Any +%msg_vars = hash()) { 
     38submethod BUILD (Str :$msg_key is required, Any :%msg_vars = hash()) { 
    3939 
    4040    throw 'invalid arg' 
     
    8888########################################################################### 
    8989 
    90 submethod BUILD (Str +@set_names is required, 
    91         Str +@member_names is required) { 
     90submethod BUILD (Str :@set_names is required, 
     91        Str :@member_names is required) { 
    9292 
    9393    throw 'invalid arg' 
  • ext/Test/lib/Test.pm

    r7414 r7752  
    3636## ok 
    3737 
    38 sub ok (Bool $cond, Str ?$desc, +$todo, +$depends) returns Bool is export { 
     38sub ok (Bool $cond, Str ?$desc, :$todo, :$depends) returns Bool is export { 
    3939    Test::proclaim($cond, $desc, $todo, :depends($depends)); 
    4040} 
     
    4242## is 
    4343 
    44 sub is (Str $got, Str $expected, Str ?$desc, +$todo, +$depends) returns Bool is export { 
     44sub is (Str $got, Str $expected, Str ?$desc, :$todo, :$depends) returns Bool is export { 
    4545    my $test := $got eq $expected; 
    4646    Test::proclaim($test, $desc, $todo, $got, $expected, $depends); 
     
    4848 
    4949## is_deeply 
    50 sub is_deeply(Any $wanted, Any $got, Str ?$desc, +$todo, +$depends) returns Bool is export { 
     50sub is_deeply(Any $wanted, Any $got, Str ?$desc, :$todo, :$depends) returns Bool is export { 
    5151    # hack for now 
    5252    my $got_perl = $got.perl; 
     
    5959## isnt 
    6060 
    61 sub isnt (Str $got, Str $expected, Str ?$desc, +$todo, +$depends) returns Bool is export { 
     61sub isnt (Str $got, Str $expected, Str ?$desc, :$todo, :$depends) returns Bool is export { 
    6262    my $test := not($got eq $expected); 
    6363    Test::proclaim($test, "Should not match: $desc", $todo, $got, $expected, $depends, :negate); 
     
    6666## like 
    6767 
    68 sub like (Str $got, Rule $expected, Str ?$desc, +$todo, +$depends) returns Bool is export { 
     68sub like (Str $got, Rule $expected, Str ?$desc, :$todo, :$depends) returns Bool is export { 
    6969    my $test := $got ~~ $expected; 
    7070    Test::proclaim($test, $desc, $todo, $got, $expected, $depends); 
     
    7373## unlike 
    7474 
    75 sub unlike (Str $got, Rule $expected, Str ?$desc, +$todo, +$depends) returns Bool is export { 
     75sub unlike (Str $got, Rule $expected, Str ?$desc, :$todo, :$depends) returns Bool is export { 
    7676    my $test := not($got ~~ $expected); 
    7777    Test::proclaim($test, $desc, $todo, $got, $expected, $depends, :negate); 
     
    8080## eval_ok 
    8181 
    82 sub eval_ok (Str $code, Str ?$desc, +$todo, +$depends) returns Bool is export { 
     82sub eval_ok (Str $code, Str ?$desc, :$todo, :$depends) returns Bool is export { 
    8383    my $result := eval $code; 
    8484    if (defined $!) { 
     
    9393## eval_is 
    9494 
    95 sub eval_is (Str $code, Str $expected, Str ?$desc, +$todo, +$depends) returns Bool is export { 
     95sub eval_is (Str $code, Str $expected, Str ?$desc, :$todo, :$depends) returns Bool is export { 
    9696    my $result := eval $code; 
    9797    if (defined $!) { 
     
    106106## cmp_ok 
    107107 
    108 sub cmp_ok (Str $got, Code &compare_func, Str $expected, Str ?$desc, +$todo, +$depends) returns Bool is export { 
     108sub cmp_ok (Str $got, Code &compare_func, Str $expected, Str ?$desc, :$todo, :$depends) returns Bool is export { 
    109109    my $test := compare_func($got, $expected); 
    110110    Test::proclaim($test, $desc, $todo, $got, "&compare_func.name() $expected", $depends); 
     
    113113## isa_ok 
    114114 
    115 sub isa_ok (Any|Junction|Pair $ref is rw, Str $expected_type, Str ?$desc, +$todo, +$depends) returns Bool is export { 
     115sub isa_ok (Any|Junction|Pair $ref is rw, Str $expected_type, Str ?$desc, :$todo, :$depends) returns Bool is export { 
    116116    my $out := defined($desc) ?? $desc !! "The object is-a '$expected_type'"; 
    117117    my $test := $ref.isa($expected_type); 
     
    121121## use_ok 
    122122 
    123 sub use_ok (Str $module, +$todo, +$depends) is export { 
     123sub use_ok (Str $module, :$todo, :$depends) is export { 
    124124    my $caller = caller().package; 
    125125     
     
    140140## throws ok 
    141141 
    142 sub throws_ok (Code &code, Any $match, Str ?$desc, +$todo, +$depends) returns Bool is export { 
     142sub throws_ok (Code &code, Any $match, Str ?$desc, :$todo, :$depends) returns Bool is export { 
    143143    try { code() }; 
    144144    if ($!) { 
     
    152152## dies_ok 
    153153 
    154 sub dies_ok (Code &code, Str ?$desc, +$todo, +$depends) returns Bool is export { 
     154sub dies_ok (Code &code, Str ?$desc, :$todo, :$depends) returns Bool is export { 
    155155    try { code() }; 
    156156    if ($!) { 
     
    164164## lives ok 
    165165 
    166 sub lives_ok (Code &code, Str ?$desc, +$todo, +$depends) returns Bool is export { 
     166sub lives_ok (Code &code, Str ?$desc, :$todo, :$depends) returns Bool is export { 
    167167    try { code() }; 
    168168    if ($!) { 
     
    176176## misc. test utilities 
    177177 
    178 multi sub skip (Str ?$reason, +$depends) returns Bool is export { 
     178multi sub skip (Str ?$reason, :$depends) returns Bool is export { 
    179179    Test::proclaim(1, "", "skip $reason", :depends($depends)); 
    180180} 
    181181 
    182 multi sub skip (Int $count, Str $reason, +$depends) returns Bool is export { 
     182multi sub skip (Int $count, Str $reason, :$depends) returns Bool is export { 
    183183    for (1 .. $count) { 
    184184        # Hack -- PIL2JS doesn't support multisubs correctly yet 
     
    191191} 
    192192 
    193 sub skip_rest (Str ?$reason, +$depends) returns Bool is export { 
     193sub skip_rest (Str ?$reason, :$depends) returns Bool is export { 
    194194    Test::skip($Test::num_of_tests_planned - $Test::num_of_tests_run, $reason // "", :depends($depends)); 
    195195} 
     
    199199} 
    200200 
    201 sub fail (Str ?$desc, +$todo, +$depends) returns Bool is export { 
     201sub fail (Str ?$desc, :$todo, :$depends) returns Bool is export { 
    202202    Test::proclaim(0, $desc, $todo, :depends($depends)); 
    203203} 
     
    363363== Testing Functions 
    364364 
    365 - `use_ok (Str $module, Bool +$todo, Str +$depends) returns Bool` 
     365- `use_ok (Str $module, Bool :$todo, Str :$depends) returns Bool` 
    366366 
    367367*NOTE:* This function currently uses `require()` since Pugs does not yet have 
    368368a proper `use()` builtin. 
    369369 
    370 - `ok (Bool $cond, Str ?$desc, Bool +$todo, Str +$depends) returns Bool` 
    371  
    372 - `is (Str $got, Str $expected, Str ?$desc, Bool +$todo, Str +$depends) returns Bool` 
    373  
    374 - `isnt (Str $got, Str $expected, Str ?$desc, Bool +$todo, Str +$depends) returns Bool` 
    375  
    376 - `like (Str $got, Rule $expected, Str ?$desc, Bool +$todo, Str +$depends) returns Bool is export` 
    377 - `unlike (Str $got, Rule $expected, Str ?$desc, Bool +$todo, Str +$depends) returns Bool is export` 
     370- `ok (Bool $cond, Str ?$desc, Bool :$todo, Str :$depends) returns Bool` 
     371 
     372- `is (Str $got, Str $expected, Str ?$desc, Bool :$todo, Str :$depends) returns Bool` 
     373 
     374- `isnt (Str $got, Str $expected, Str ?$desc, Bool :$todo, Str :$depends) returns Bool` 
     375 
     376- `like (Str $got, Rule $expected, Str ?$desc, Bool :$todo, Str :$depends) returns Bool is export` 
     377- `unlike (Str $got, Rule $expected, Str ?$desc, Bool :$todo, Str :$depends) returns Bool is export` 
    378378 
    379379These functions should work with most reg-exps, but given that they are still a 
     
    381381too funky. 
    382382 
    383 - `cmp_ok (Str $got, Code &compare_func, Str $expected, Str ?$desc, Bool +$todo, Str +$depends) returns Bool` 
     383- `cmp_ok (Str $got, Code &compare_func, Str $expected, Str ?$desc, Bool :$todo, Str :$depends) returns Bool` 
    384384 
    385385This function will compare `$got` and `$expected` using `&compare_func`. This will 
     
    393393  cmp_ok('test', sub ($a, $b) { ?($a gt $b) }, 'me', '... testing gt on two strings'); 
    394394 
    395 - `isa_ok ($ref, Str $expected_type, Str ?$desc, Bool +$todo, Str +$depends) returns Bool` 
     395- `isa_ok ($ref, Str $expected_type, Str ?$desc, Bool :$todo, Str :$depends) returns Bool` 
    396396 
    397397This function currently on checks with ref() since we do not yet have 
     
    399399maintain backwards compatibility as well. 
    400400 
    401 - `eval_ok (Str $code, Str ?$desc, Bool +$todo, Str +$depends) returns Bool` 
    402  
    403 - `eval_is (Str $code, Str $expected, Str ?$desc, Bool +$todo, Str +$depends) returns Bool` 
     401- `eval_ok (Str $code, Str ?$desc, Bool :$todo, Str :$depends) returns Bool` 
     402 
     403- `eval_is (Str $code, Str $expected, Str ?$desc, Bool :$todo, Str :$depends) returns Bool` 
    404404 
    405405These functions will eval a code snippet, and then pass the result to is or ok 
    406406on success, or report that the eval was not successful on failure. 
    407407 
    408 - `throws_ok (Code &code, Any $expected, Str ?$desc, Bool +$todo, Str +$depends) returns Bool` 
     408- `throws_ok (Code &code, Any $expected, Str ?$desc, Bool :$todo, Str :$depends) returns Bool` 
    409409 
    410410This function takes a block of code and runs it. It then smart-matches (`~~`) any `$!`  
    411411value with the `$expected` value. 
    412412 
    413 - `dies_ok (Code &code, Str ?$desc, Bool +$todo, Str +$depends) returns Bool` 
    414  
    415 - `lives_ok (Code &code, Str ?$desc, Bool +$todo, Str +$depends) returns Bool` 
     413- `dies_ok (Code &code, Str ?$desc, Bool :$todo, Str :$depends) returns Bool` 
     414 
     415- `lives_ok (Code &code, Str ?$desc, Bool :$todo, Str :$depends) returns Bool` 
    416416 
    417417These functions both take blocks of code, run the code, and test whether they live or die. 
     
    447447functions and its compliment the fail() function. 
    448448 
    449 - `fail (Str ?$desc, Bool +$todo) returns Bool` 
     449- `fail (Str ?$desc, Bool :$todo) returns Bool` 
    450450 
    451451This is the opposite of pass() 
  • ext/URI/lib/URI/Escape.pm

    r6852 r7752  
    1414    #} 
    1515     
    16     multi sub uri_escape (Str $string is copy, Str $unsafe, Bool +$negate) returns Str is export(:DEFAULT) { 
     16    multi sub uri_escape (Str $string is copy, Str $unsafe, Bool :$negate) returns Str is export(:DEFAULT) { 
    1717        my $pattern; 
    1818         
  • ext/libwww-perl/lib/HTTP/Headers.pm

    r6918 r7752  
    302302} 
    303303 
    304 method redirect (::?CLASS ::class: Str $location, Str ?$target, Str ?$status = "302 Found", Str +$cookie, Bool +$nph, *%extra) { 
     304method redirect (::?CLASS ::class: Str $location, Str ?$target, Str ?$status = "302 Found", Str :$cookie, Bool :$nph, *%extra) { 
    305305    my $h = ::class.new(); 
    306306     
  • ext/libwww-perl/lib/HTTP/Response.pm

    r6146 r7752  
    1313    has $.request   is rw; 
    1414     
    15     submethod BUILD (+$.code, +$.message) { } 
     15    submethod BUILD (:$.code, :$.message) { } 
    1616     
    1717    method parse (Str $str is copy) { 
  • perl5/PIL-Run/lib6/P5Runtime/PrimP6.pm

    r7181 r7752  
    9999} 
    100100 
    101 multi sub eval($code,+$langpair = undef) { 
     101multi sub eval($code,:$langpair = undef) { 
    102102    my $lang = "Perl6"; 
    103103    try { $lang = $langpair.value }; # XXX - pilrun multi-bug workaround 
  • perl5/PIL2JS/lib6/Prelude/JS.pm