=head1 NAME

Perl6::Overview::Operator - Operators

=head1 DESCRIPTION

=head2 Precedence

    terms               42 3.14 "eek" qq["foo"] [1,2,3] {...} \(@a,$b,%c)
                            $x @y %z /abc/ MyType @@multidim $^a
                            (1+2) a(1) :by(2) :!verbose :(Dog $self:)
                            .meth with implicit invocant
                            listops leftward
    method postfix      .meth .+ .? .* .() .[] .{} .<> .«» .:: .= .^
    autoincrement       ++ --
    exponentiation      **
    symbolic unary      ! + - ~ ? $ @ % & +^ ~^ ?^ \ ^ =
    multiplicative      * / % x xx +& +< +> ~& ~< ~> ?&
    additive            + - ~ +| +^ ~| ~^ ?| ?^
    junctive and (all)  &
    junctive or (any)   | ^
    named unary         rand sleep abs etc. -e -r -w -x etc.
    nonchaining binary  but does <=> leg cmp
                            .. ^.. ..^ ^..^
                            ff ^ff ff^ ^ff^
                            fff ^fff fff^ ^fff^
    chaining binary     != == < <= > >=
                            eq ne lt le gt ge
                            ~~ =:= === eqv
                            !== !~~ !eq !=:= !=== !eqv etc.
    tight and           &&
    tight or            || ^^ //
    conditional         ?? !!
    item assignment     = := ::= =>
                            (also = with simple lvalues)
                            += -= **= xx= .= etc.
    loose unary         true not
    comma		,
    list infix          X Z minmax <== ==>
    list ops            = print push say join split substr open etc.
                            any all one none
                            die fail warn
                            !!! ...  ???
                            [+] [*] [<] [,] [\+] [\*] etc.
                            (also = as list assignment)
    loose and           and
    loose or            or xor err
    expr terminator     ; {} as control block, statement modifiers
                            unmatched ), ], }, etc.

=head2 Simple arithmetic operators

    4 + 2        # 6, addition
    4 - 2        # 2, subtraction
    4 * 2        # 8, multiplication
    4 / 2        # 2, division
    4 ** 2       # 16, exponentiation
    4 % 2        # 0, modulo

=head2 Bit operators

    Numeric   Stringy   Boolean
    ---------------------------
    +|        ~|        ?|           # OR
    +&        ~&        ?&           # AND
    +^        ~^        ?^           # XOR
    +^        ~^        ?^           # Negation (prefix unary)
    +<        ~<                     # Shift left
    +>        ~>                     # Shift right

=head2 Unary context operators

    +           # Num
    ~           # Str
    ?           # Bool
    int         # Int
    item        # Item
    list        # List
    hash        # Hash
    pair        # Pair

=head2 Meta-operators

    @foo >>op $bar    # hyper loop over left side
    $foo op<< @bar    # hyper loop over right side
    @foo >>op<< @bar  # hyper loop over both sides, parallel
    [+] @foo          # reduce with specified infix op
    [+] 1, 2, 3       # 1 + 2 + 3

    .= .? .* .+       # See oo

=head2 Assignment operators

    $copy = $foo     # assign
    $alias := $foo   # bind, runtime
    $alias ::= $foo  # bind, compile time
    $foo++           # postincrement
    $foo--           # postdecrement
    ++$foo           # preincrement
    --$foo           # predecrement
    $foo op= $bar    # mutate ($foo = $foo op $bar), where op is any infix

=head2 Comparison operators

    Generic   Num   Str
    -------------------
    =:=                   # equality (container)
    !=:=                  # negated equality (container)
    ===                   # equality (value, eternal semantics)
    !===                  # negated equality (value, eternal semantics)
    eqv       ==    eq    # equality (value, snapshot semantics)
    !eqv      !==   !eq   # negated equality (value, snapshot semantics)
              !=    ne    # traditional shortcuts for previous
              <     lt    # less than
              >     gt    # greater than
              <=    le    # less than or equal to
              >=    ge    # greater than or equal to
    cmp       <=>   leg   # lt => -1, eq => 0, gt => +1
    ~~                    # smart match (see smartmatch)
    !~~                   # negated smart match

In general, any infix comparison operator (that doesn't begin with a !) may
be transformed into its negative by prefixing with !.

=head2 Logic operators

    HighPrec  LowPrec
    -----------------
    &&        and       # infix
    ||        or        # infix
    ^^        xor       # infix
    //        err       # infix (defined-or)
    !         not       # prefix
    ?         true      # prefix
    ?? !!               # ternary

=head2 Quote-like operators

    Generalized Short   Shorter
    -----------------------------
    q:0
    q:1         q       ''
    q:2         qq      ""
    q:to
    q:0:w       qw      <>
    q:2:w       qww     «» <<>>    # XXX qww or qqw? :2:w correct?
                m       //
                rx      //

=head2 Junctive operators

    $foo | $bar | $baz   # any($foo, $bar, $baz)
    $foo & $bar & $baz   # all($foo, $bar, $baz)
    $foo ^ $bar ^ $baz   # one($foo, $bar, $baz)
    (no chaining op)     # none($foo, $bar, $baz)

=head2 Yada yada yada operators (terms)

    ...  # fail "$?BLOCKNAME is not yet implemented"
    ???  # warn "$?BLOCKNAME is not yet implemented"
    !!!  # die  "$?BLOCKNAME is not yet implemented"

=head2 Miscellaneous operators

    \$foo               # capture
    $foo ~ $bar         # string concat
    $foo x 3            # $foo ~ $foo ~ $foo
    $foo xx 3           # ($foo, $foo, $foo)
    @foo Z @bar Z @baz  # zip(@foo; @bar; @baz)
    @foo X @bar X @baz  # cross(@foo; @bar; @baz)
    item ($foo, $bar)   # [ $foo, $bar ]
    1..5                # (1, 2, 3, 4, 5)
    "a".."g"            # <a b c d e f g>
    ;                   # statement separator

=head2 See also

    .method         # oo
    .=method        # oo
    .()             # sub
    .[]             # data
    .{}             # data
    .<>             # data
    .<<>>           # data
    $, @, %, &, ::  # data
    k => $v         # data
    :k($v)          # data
    <==, ==>        # sub

=cut
