Changeset 17701

Show
Ignore:
Timestamp:
09/06/07 19:43:34 (15 months ago)
Author:
lwall
Message:

s:g/err/orelse/

Files:
56 modified

Legend:

Unmodified
Added
Removed
  • docs/Perl6/API/Scalar.pod

    r12817 r17701  
    5757warning in doing so. There are two ways to determine if a 
    5858value equal to undef: the C<defined> function (or method) can 
    59 be called or the C<//> (or C<err>) operator can be used. 
     59be called or the C<//> (or C<orelse>) operator can be used. 
    6060 
    6161C<undef> is also considered to be false in a boolean context. 
  • docs/Perl6/Overview/File.pod

    r15167 r17701  
    1414    # if MODE left out it defaults to :r 
    1515     
    16     my $fh = open "filename", :r err die "Could not open file $!"; 
     16    my $fh = open "filename", :r orelse die "Could not open file $!"; 
    1717 
    1818    my $row = =$fh;                           # reading a line 
     
    2727=head2 Directories 
    2828 
    29     my $dh = opendir "dirname" err die "Could not open directory $!"; 
     29    my $dh = opendir "dirname" orelse die "Could not open directory $!"; 
    3030 
    3131    my @files = readdir($dh); 
  • docs/Perl6/Spec/Functions.pod

    r17196 r17701  
    447447warning in doing so. There are two ways to determine if a 
    448448value equal to undef: the C<defined> function (or method) can 
    449 be called or the C<//> (or C<err>) operator can be used. 
     449be called or the C<//> (or C<orelse>) operator can be used. 
    450450 
    451451C<undef> is also considered to be false in a boolean context. 
  • docs/notes/precompilation_cache.pod

    r15167 r17701  
    122122      die "no precompiled version found" unless $dir ~~ :d; 
    123123      for $dir.readdir.sort:{numerically} -> $fn { 
    124           my ($pugsrev, $parserrev) = $fn ~~ /(\d+)-(\d+)/ err next; 
     124          my ($pugsrev, $parserrev) = $fn ~~ /(\d+)-(\d+)/ orelse next; 
    125125          next if $XXX_handwaving($pugsrev, $parserrev); # against %?CONFIG<pugsrev> etc. 
    126126           
    127           load_precompiled($fn) err { 
     127          load_precompiled($fn) orelse { 
    128128              $fn.rm; 
    129129              die "error loading cached version: $!"; 
  • docs/notes/unicode_draft

    r13280 r17701  
    215215 
    216216    # but you can handle it with 
    217     $x err die "..." 
     217    $x orelse die "..." 
    218218    if $x { ... } 
  • docs/other/porting_howto

    r16318 r17701  
    241241 
    242242  - open() 
    243        open my $fh, "<", $filename or die $!;    ->   my $fh = open($filename, :r) err die $!; 
     243       open my $fh, "<", $filename or die $!;    ->   my $fh = open($filename, :r) orelse die $!; 
    244244 
    245245       "<"   -> :r 
  • docs/tutorial/ch04_basic_syntax.pod

    r16700 r17701  
    449449keyword: 
    450450 
    451   my $pi is constant = 3.14159; 
    452  
    453 The C<constant> trait specifies that the value of the variable can't 
     451  my $pi is readonly = 3.14159; 
     452 
     453The C<readonly> trait specifies that the value of the variable can't 
    454454be changed. 
    455455 
     
    459459keyword: 
    460460 
    461   $true_value = 0 but true; 
    462  
    463 The C<true> property specifies that the value will evaluate as true in 
     461  $true_value = 0 but True; 
     462 
     463The C<True> property specifies that the value will evaluate as true in 
    464464a boolean context, no matter what the actual value is. This particular 
    465 property means the Perl 6 C<system> call can be checked with a simple 
     465property means the Perl 6 C<run> call can be checked with a simple 
    466466conditional. It still returns the same numeric values it always has (0 
    467467on success and a numeric error code on failure), but it flags the 
     
    488488more precisely than Perl 5, but keep in mind that explicit types are 
    489489completely optional. If you choose to use them, you'll gain some 
    490 benefits in optimization and interfacing between languages. The design 
    491 of the type system isn't complete, but the basic groundwork is in 
    492 place. 
     490benefits in optimization and interfacing between languages.  The biggest 
     491benefit, however, is that types enable fine-grained control of multiple dispatch 
     492when you want it, or course-grained contol when you don't care. 
    493493 
    494494Perl 6 makes a distinction between the type of a value and the type of 
     
    508508 
    509509  my Int %hash; 
     510 
     511The type of the keys may be declared in a pseudo-subscript.  Since the 
     512default key type is strings, the preceding declaration is actually short for: 
     513 
     514  my Int %hash{Str}; 
     515 
     516To declare a hash that uses any object type for a key and always returns, 
     517say, an icon object, say: 
     518 
     519  my Icon %hash{Any} 
    510520 
    511521The I<variable> type specifies what kind of container the variable is. 
     
    698708  @range = 3..Inf; # lazy 
    699709 
    700 X<. (dot);... (infinite range);operator> 
    701 The C<...> operator is equivalent to C<..Inf>: 
    702  
    703   @range = 3...; 
     710The C<*> token may be used instead of C<Inf>, which really only makes sense 
     711for numeric types: 
     712 
     713  @range = 3..*; 
     714  @range = 'a'..*; 
    704715 
    705716=head2 Comparison 
     
    739750are aliases to the same object. Each returns a true value if the 
    740751relation is true and a false value otherwise. The generic comparison 
    741 operators (C<E<lt>=E<gt>>, C<cmp>) return C<0> if the two arguments are 
     752operators (C<E<lt>=E<gt>>, C<leg>) return C<0> if the two arguments are 
    742753equal, C<1> if the first is greater, and C<-1> if the second is greater. 
    743754 
    744   if ($age > 12) {...} 
     755  if $age > 12 {...} 
    745756 
    746757Comparison operators can also be chained. Chained comparisons  
    747758evaluate each value in the chain only once. 
    748759 
    749   if (24 < $age < 42) {...} # 24 < $age and $age < 42 
     760  if 24 < $age < 42 {...} # 24 < $age and $age < 42 
    750761 
    751762=head2 Logical Operators 
     
    780791  $splat = ($whale or $petunia); 
    781792 
    782 X<err (test defined) operator> 
     793X<orelse (test defined) operator> 
    783794X</ (slash);// (test defined) operator> 
    784795A variant of the OR relation tests for definedness instead of truth. 
    785 It uses the C<//> operator and the low-precedence C<err> operator. The 
     796It uses the C<//> operator and the low-precedence C<orelse> operator. The 
    786797left-hand value is returned if it is defined, otherwise the right-hand 
    787798side is evaluated and its value returned: 
    788799 
    789800  $splat = $whale // $petunia; 
    790   $splat = ($whale err $petunia); 
     801  $splat = ($whale orelse $petunia); 
    791802 
    792803X<xor operator>  
     
    10951106shortly. So while C<||> is a logical operation on two expressions: 
    10961107 
    1097   if ($value == 1) || ($value == 2) { ... } 
     1108  if $value == 1 || $value == 2 { ... } 
    10981109 
    10991110C<|> is the same logical relation between two values: 
     
    11131124 
    11141125  $junc = 1 | 2; 
    1115   if ($value == $junc) { ... } 
     1126  if $value == $junc { ... } 
    11161127 
    11171128Here, the variable C<$junc> is used in place of C<1 | 2>, and has 
     
    12331244operators that's: 
    12341245 
    1235   if ($a != $c) && ($a != $d) && ($b != $c) && ($b != $d) { ... } 
     1246  if $a != $c && $a != $d && $b != $c && $b != $d { ... } 
    12361247 
    12371248If you want to get back a flat list of values from a junction, use the 
     
    16571668Z<CHP-4-SECT-3.1.1> 
    16581669 
    1659 X<if (conditional);statement> 
     1670X<if conditional;statement> 
    16601671The C<if> statement checks a condition and executes its associated 
    16611672block only if that condition is true. The condition can be any 
  • docs/tutorial/ch07_grammars.pod

    r16690 r17701  
    4545X<~ (tilde);~~ (smart match) operator> 
    4646 
    47   if ($string ~~ m/\w+/)      {...} 
    48   if ($string ~~ s/\w+/word/) {...} 
    49   if ($string ~~ /\w+/)       {...} 
     47  if $string ~~ m/\w+/      {...} 
     48  if $string ~~ s/\w+/word/ {...} 
     49  if $string ~~ /\w+/       {...} 
    5050 
    5151You can substitute other delimiters, like C<#...#>, C<[...]>, and 
    5252C<{...}> for the standard C</.../>, though C<?...?> and C<(...)> are 
    53 not valid delimiters.  
    54  
    55   if ($string ~~ s[\w+][word]) {...} 
     53not valid delimiters: 
     54 
     55  $string ~~ s/\w+/word/ 
     56 
     57Modifiers now come in front using I<adverb> syntax, so to do multiple 
     58substitutions on the same string is: 
     59 
     60  $string ~~ s:g/\w+/word/ 
     61 
     62Also, if you use brackets on the first part of a substitution, the second 
     63part is specified as a pseudoassignment: 
     64 
     65  $string ~~ s[\w+] = 'word'; 
     66 
     67This form also allows assignment operators, so if you want to add one to 
     68all the number within a string, you can say: 
     69 
     70  $string ~~ s:g[\d+] += 1; 
    5671 
    5772=head2 Deferred Matches 
  • examples/advocacy/motd-i.pl

    r15167 r17701  
    1414my $dict = canonpath("$progdir/pugspraise"); 
    1515 
    16 my $fh = open($dict) err die $!; 
     16my $fh = open($dict) orelse die $!; 
    1717 
    1818for =$fh->$line { 
  • examples/advocacy/motd.pl

    r11293 r17701  
    1212my $limit     = @*ARGS[0] // '2'; 
    1313my $dict      = canonpath("$progdir/pugspraise"); 
    14 my $fh        = open $dict err die $!; 
     14my $fh        = open $dict orelse die $!; 
    1515my @list      = =$fh; 
    1616 
  • examples/cookbook/07file-access/07-01opening_file.pl

    r11293 r17701  
    1010 
    1111my $input = open($path, :r) 
    12     err die "Could not open $path for reading $!\n"; 
     12    orelse die "Could not open $path for reading $!\n"; 
    1313 
    1414my $filename = "test_file"; 
    1515my $output = open($filename, :w)  
    16     err die "Could not open $filename for writing $!\n"; 
     16    orelse die "Could not open $filename for writing $!\n"; 
    1717 
    1818 
     
    2929 
    3030# Closing the file 
    31 # $input.close err die $!; 
     31# $input.close orelse die $!; 
    3232# close($input); 
    3333 
  • examples/cookbook/07file-access/07-04making_perl_report_filenames_in_error_messages.pl

    r11293 r17701  
    99 
    1010#my $fh = open($path) 
    11 #    err die "Could not open '$path' for reading: $!\n"; 
     11#    orelse die "Could not open '$path' for reading: $!\n"; 
    1212  
  • examples/games/hangman.pl

    r12799 r17701  
    1818sub get_committer_list (Str $dict_file) returns List { 
    1919    my @committers; 
    20     my $dict = open($dict_file) err die "Couldn't open the AUTHORS file.\nYou must run this script from within the main pugs\ndirectory or within the examples/ sub-directory."; 
     20    my $dict = open($dict_file) orelse die "Couldn't open the AUTHORS file.\nYou must run this script from within the main pugs\ndirectory or within the examples/ sub-directory."; 
    2121 
    2222    # Skip the intro text 
  • examples/games/hangman.pod

    r6851 r17701  
    1111=head1 sub get_committer_list 
    1212 
    13 C<err> is the low precedence form of C<//> (S03). C<//> is especially useful 
     13C<orelse> is the low precedence form of C<//> (S03). C<//> is especially useful 
    1414in its assignment form: 
    1515 
    1616    $x //= $y; 
    1717 
    18 To summarize, C<||> and C<or> relate to truth, while C<//> and C<err> relate 
     18To summarize, C<||> and C<or> relate to truth, while C<//> and C<orelse> relate 
    1919to definedness. 
    2020 
  • examples/golf/tsanta.pl

    r15167 r17701  
    2424 
    2525sub golf_score (Str $script) returns Int { 
    26     my $fh = open($script) err die("open '$script' failed: $!"); 
     26    my $fh = open($script) orelse die("open '$script' failed: $!"); 
    2727    my $golf = 0; 
    2828    my $dollar_dot = 0;    # Note: $. aka $fh.linenum() not implemented yet 
     
    3232            unless $dollar_dot==1 && $line.index("#!") == 0; 
    3333    } 
    34     $fh.close() err die("close '$script' failed: $!"); 
     34    $fh.close() orelse die("close '$script' failed: $!"); 
    3535    return $golf; 
    3636} 
     
    4343 
    4444sub build_file (Str $fname, Str $data) { 
    45     my $fh = open($fname, :w) err die("open '$fname' failed: $!"); 
    46     $fh.print($data) err die("print '$fname' failed: $!"); 
    47     $fh.close() err die("close '$fname' failed: $!"); 
     45    my $fh = open($fname, :w) orelse die("open '$fname' failed: $!"); 
     46    $fh.print($data) orelse die("print '$fname' failed: $!"); 
     47    $fh.close() orelse die("close '$fname' failed: $!"); 
    4848} 
    4949 
     
    5353    print("$label: running: '$cmd'..."); 
    5454    # my $out = `$cmd`; 
    55     system($cmd) err die("system '$cmd' failed: $!"); 
     55    system($cmd) orelse die("system '$cmd' failed: $!"); 
    5656    # XXX: get return code. how? $!? (I think $? is obsolete in p6). 
    5757    my $rc = 0; 
    58     my $out = slurp($outtmp) err die("slurp '$outtmp' failed: $!"); 
     58    my $out = slurp($outtmp) orelse die("slurp '$outtmp' failed: $!"); 
    5959    # my $rc = $? >> 8; 
    6060    say("done (rc=$rc)"); 
  • examples/irclog2html.pl

    r13342 r17701  
    7272 
    7373# Pass I 
    74 my $fh = open @*ARGS[0] err die "Couldn't open \"@*ARGS[0]\": $!\n"; 
     74my $fh = open @*ARGS[0] orelse die "Couldn't open \"@*ARGS[0]\": $!\n"; 
    7575my $total = 0; 
    7676 
     
    9999 
    100100# Pass I 
    101 $fh = open @*ARGS[0] err die "Couldn't open \"@*ARGS[0]\": $!\n"; 
     101$fh = open @*ARGS[0] orelse die "Couldn't open \"@*ARGS[0]\": $!\n"; 
    102102 
    103103# This is the main coderef which processes a logline and returns HTML. 
  • examples/matrix.pl

    r16636 r17701  
    6969 
    7070gather { 
    71     for slurp '/usr/share/dict/words' :chomp err die { 
     71    for slurp '/usr/share/dict/words' :chomp orelse die { 
    7272        next if /<-[a-z]>/; 
    7373        /$re/ and take { word => $_, score => %scores{ .letters }.sum }; 
  • examples/naive_bayesian/naive_bayesian.pl

    r15167 r17701  
    55sub load_db returns Void { 
    66    return() unless "words.db.pl" ~~ :e; 
    7     my $db = open("words.db.pl") err die "Cannot open the words.db.pl file: $!"; 
     7    my $db = open("words.db.pl") orelse die "Cannot open the words.db.pl file: $!"; 
    88    for (=$db) -> $_line { 
    99        my $line = $_line; 
     
    1515 
    1616sub save_db returns Void { 
    17     my $db = open("words.db.pl", :w) err die "Cannot open the words.db.pl file: $!"; 
     17    my $db = open("words.db.pl", :w) orelse die "Cannot open the words.db.pl file: $!"; 
    1818    for (%words.kv) -> $key, $value { 
    1919        $db.say($key ~ "\t" ~ $value); 
     
    2424sub parse_file (Str $file) returns Hash { 
    2525    my %words_in_file;     
    26     my $fh = open("$file") err die "Cannot open the '$file' file: $!"; 
     26    my $fh = open("$file") orelse die "Cannot open the '$file' file: $!"; 
    2727    for (=$fh) -> $_line { 
    2828        my $line = $_line;        
  • examples/network/hangmanbot.pl

    r12807 r17701  
    2020sub get_committer_list(Str $dict_file) returns List { 
    2121  my @committers; 
    22   my $dict = open($dict_file) err 
     22  my $dict = open($dict_file) orelse 
    2323    die "Couldn't open \"$dict_file\": $!\n"; 
    2424 
  • examples/p6explain/p6explain

    r11293 r17701  
    66 
    77# Parsing the dat 
    8 my $fh = open $dat err die "Couldn't open \"$dat\" for reading: $!\n"; 
     8my $fh = open $dat orelse die "Couldn't open \"$dat\" for reading: $!\n"; 
    99for =$fh { 
    1010  state $cur_entry; 
  • examples/password-manager.p6

    r16177 r17701  
    9090 
    9191sub xclip(Str $s -->) { 
    92         my IO $xclip = Pipe.to: 'xclip' err abort 'No xclip - use .p'; 
     92        my IO $xclip = Pipe.to: 'xclip' orelse abort 'No xclip - use .p'; 
    9393        $xclip.print: $s; 
    9494        $xclip.close; 
     
    9898        my Str $pw = %pw{$s}<pass> // 
    9999                first Str, (%pw{$_}<pass> if /$s/ for %pw.keys) 
    100                 err abort "Couldn't find account $s"; 
     100                orelse abort "Couldn't find account $s"; 
    101101        xclip $pw; 
    102102        cmt if $changed; 
     
    117117 
    118118sub cmt(-->) { 
    119         unlink 'pwd.gpg.old' err abort "Couldn't unlink: $!"; 
    120         rename 'pwd.gpg', 'pwd.gpg.old' err abort "Couldn't rename: $!"; 
     119        unlink 'pwd.gpg.old' orelse abort "Couldn't unlink: $!"; 
     120        rename 'pwd.gpg', 'pwd.gpg.old' orelse abort "Couldn't rename: $!"; 
    121121        my IO $pwd = Pipe.to: 'gpg --symmetric --force-mdc --cipher-algo AES256 --output pwd.gpg' 
    122                 err abort "Couldn't encrypt: $!"; 
     122                orelse abort "Couldn't encrypt: $!"; 
    123123        for %pw.keys -> $k { $pwd.say: $k, "\t", %pw{$k}<pass user>.join("\t") } 
    124124        if $pwd.close { 
     
    168168%*ENV<PATH> = '/bin:/usr/bin:/usr/bin/X11'; 
    169169umask 0o77; 
    170 chdir "$+HOME/pw" err die "Couldn't cd: $!"; 
    171 my IO $pwd = Pipe.from: 'gpg --output - --decrypt pwd.gpg' err die "Couldn't decrypt: $!"; 
     170chdir "$+HOME/pw" orelse die "Couldn't cd: $!"; 
     171my IO $pwd = Pipe.from: 'gpg --output - --decrypt pwd.gpg' orelse die "Couldn't decrypt: $!"; 
    172172for =$pwd { 
    173173        /<pwent>/ or die 'Malformed line ', $pwd.linenum, ": $_\n"; 
  • examples/perl5/cpan-upload.pl

    r15167 r17701  
    230230    #------------------------------------------------------------------- 
    231231    _debug("  creating instance of LWP::UserAgent\n"); 
    232     $agent = LWP::UserAgent.new() err die "Failed to create UserAgent: $!\n"; 
     232    $agent = LWP::UserAgent.new() orelse die "Failed to create UserAgent: $!\n"; 
    233233    $agent.agent("$PROGRAM/$VERSION"); 
    234234    $agent.from($config.mailto); 
  • examples/perldoc.pl

    r15167 r17701  
    4646sub display_pod { 
    4747    my ($podfile) = @_; 
    48     my $fh = open $podfile err die "Could not open '$podfile'\n"; 
     48    my $fh = open $podfile orelse die "Could not open '$podfile'\n"; 
    4949    for =$fh -> $line { 
    5050        say $line; 
     
    6262    for list_files(dirname($PROGRAM_NAME)) -> $podfile { 
    6363        say "Processing '$podfile'"; 
    64         my $fh = open $podfile err die "Could not open '$podfile'\n"; 
     64        my $fh = open $podfile orelse die "Could not open '$podfile'\n"; 
    6565        my $row = 0; 
    6666        my $section; 
     
    8686sub list_files ($dir, $full) {