www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Operator Precedence and Associativity

reply "Tyro[17]" <ridimz yahoo.com> writes:
I’m sure the following table is missing a few items but am unclear
what they are. For starters these <>, <>=, >>>, , !<>, !<>=
belong on the table but I’m not sure where. I am also not sure if

or missing operators. Request assist to complete correctly.


           Operator Precedence and Associativity Rules in D
———————————————————————————————————————————————————————————————————
     !           template instantiation
———————————————————————————————————————————————————————————————————
     =>          lambda                                right-to-left
———————————————————————————————————————————————————————————————————
     ()          function call                         left-to-right
     []          array element
     .           member selection
     ++          post increment                        right-to-left
     --          post decrement
———————————————————————————————————————————————————————————————————
     !           logical not                           right-to-left
     ~           bitwise complement
     -           unary minus
     ++          pre increment
     --          pre decrement
     *           contents of (dereference)
     new
     ref
     in
     !in
     out
     inout
     cast()
     is
     !is
———————————————————————————————————————————————————————————————————
     ^^          power                                 left-to-right
     *           multiply
     /           divide
     %           remainder
———————————————————————————————————————————————————————————————————
     +           add                                   left-to-right
     -           subtract
———————————————————————————————————————————————————————————————————
     <<          bitwise left shift                    left-to-right
     >>          bitwise right shift
———————————————————————————————————————————————————————————————————
     <           arithmetic less than                  left-to-right
     !>=         arithmetic not greater than or equal to
     >           arithmetic greater than
     !<=         arithmetic not less than or equal to
     <=          arithmetic less than or equal to
     !>          arithmetic not greater than
     >=          arithmetic greater than or equal to
     !<          arithmetic not less than
———————————————————————————————————————————————————————————————————
     ==          arithmetic equal                      left-to-right
     !=          arithmetic not equal
———————————————————————————————————————————————————————————————————
     &           bitwise and                           left-to-right
———————————————————————————————————————————————————————————————————
     ^           bitwise exclusive or                  left-to-right
———————————————————————————————————————————————————————————————————
     |           bitwise or                            left-to-right
———————————————————————————————————————————————————————————————————
     &&          logical and                           left-to-right
———————————————————————————————————————————————————————————————————
     ||          logical or                            left-to-right
———————————————————————————————————————————————————————————————————
     ? :         conditional expression                right-to-left
———————————————————————————————————————————————————————————————————
     =           assignment operator                   right-to-left
     also +=    -=    *=    /=    %=
     <<=    >>=    &=    ^=    |=
     ~=    ^^=    >>>=
———————————————————————————————————————————————————————————————————
     =>          lambda                                left-to-right
———————————————————————————————————————————————————————————————————
     ,           sequential expression                 left-to-right
———————————————————————————————————————————————————————————————————
     ..          range separator
———————————————————————————————————————————————————————————————————

-- 

Andrew Edwards
--------------------
http://www.akeron.co
auto getAddress() {
     string location = " ", period = ".";
     return ("info" ~ location ~ "afidem" ~ period ~ "org");
}
Nov 05 2013
next sibling parent reply Jonathan M Davis <jmdavisProg gmx.com> writes:
On Tuesday, November 05, 2013 22:34:49 Tyro[17] wrote:
 I=E2=80=99m sure the following table is missing a few items but am un=
clear
 what they are. For starters these <>, <>=3D, >>>, , !<>, !<>=3D
 belong on the table but I=E2=80=99m not sure where.
I'm not quite sure where they go, but I believe that all of them (save = maybe=20
) are supposed to be deprecated, in which case, it matters a lot les=
s where=20 they'd go in the table. - Jonathan M Davis
Nov 05 2013
parent "Tyro[17]" <ridimz yahoo.com> writes:
On 11/5/13, 11:36 PM, Jonathan M Davis wrote:
 On Tuesday, November 05, 2013 22:34:49 Tyro[17] wrote:
 I’m sure the following table is missing a few items but am unclear
 what they are. For starters these <>, <>=, >>>, , !<>, !<>=
 belong on the table but I’m not sure where.
I'm not quite sure where they go, but I believe that all of them (save maybe
 ) are supposed to be deprecated, in which case, it matters a lot less where
they'd go in the table. - Jonathan M Davis
OK thanks. As for the actual chart, I take it there wasn't anything glaringly wrong with what's already in it? Andrew
Nov 07 2013
prev sibling parent reply Timon Gehr <timon.gehr gmx.ch> writes:
On 11/06/2013 04:34 AM, Tyro[17] wrote:
 I’m sure the following table is missing a few items but am unclear
 what they are. For starters these <>, <>=, >>>, , !<>, !<>=
 belong on the table but I’m not sure where. I am also not sure if

 or missing operators. Request assist to complete correctly.
 ...
I have some time ago compiled my own table, which can be found here: http://wiki.dlang.org/Operator_precedence
Nov 06 2013
parent "Tyro[17]" <ridimz yahoo.com> writes:
On 11/6/13, 6:43 AM, Timon Gehr wrote:
 On 11/06/2013 04:34 AM, Tyro[17] wrote:
 I’m sure the following table is missing a few items but am unclear
 what they are. For starters these <>, <>=, >>>, , !<>, !<>=
 belong on the table but I’m not sure where. I am also not sure if

 or missing operators. Request assist to complete correctly.
 ...
I have some time ago compiled my own table, which can be found here: http://wiki.dlang.org/Operator_precedence
Thanks. Did not see this earlier. I will compare my list and adjust accordingly.
Nov 07 2013