Re: [go-nuts] Presidence of Operators

2018-12-14 Thread fgergo
(please reply to the list, so others with a similar question can find
this thread.)

I'm sorry, I should have made it clear: for me it's hard to parse the question.
I'll try again: could you please write 1 working example in
play.golang.org with the assumed precedence rules?
If you could share a link to that example in your reply, that would
help clarify the question. (Use the share button on play.golang.org to
show a link to be shared.)

On 12/14/18, 伊藤和也  wrote:
> OUnary operators have the highest precedence.
> According to go language specification, unary operators have the highest
> precedence means binary operators are the 2nd highest precedence maybe.
> and binary operators also have the precedence in 5 levels. When I use
> parentheses with unary operators, unary operators are evaluated first and
> when I use parentheses with binary operators,  parentheses are evaluated
> first.
> Example of parentheses with binary operators
>
> fmt.Println(false && (false || true))
>
> fmt.Println(false && false || true)
>
> There is no example of  parentheses with unary operators.
> Yes, parenthesis isn't an operator, it's a punctuation.
> So can I say the precedence of parethesis which is a parenthesis is lower
> than unary operators and
> higher than binary operators.
> unary operators  (high)
>↑
> parentheses   ↑
>↑
> binary operators  (low)
> 2018年12月14日(金) 19:15 :
>
>> Could you please give 2 examples, where the results depend on the
>> precedence? Maybe on play.golang.org ?
>> Maybe this also helps: https://golang.org/ref/spec#Operators
>>
>> On 12/14/18, 伊藤和也  wrote:
>> > Can I say the precedence of paretheses are lower than unary operators
>> > and
>> > higher than binary operators.
>> > unary operators  (high)
>> >   ↑
>> >   parentheses ↑
>> > ↑
>> > binary operators  (low)
>> >
>> > --
>> > You received this message because you are subscribed to the Google
>> > Groups
>> > "golang-nuts" group.
>> > To unsubscribe from this group and stop receiving emails from it, send
>> > an
>> > email to golang-nuts+unsubscr...@googlegroups.com.
>> > For more options, visit https://groups.google.com/d/optout.
>> >
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] Presidence of Operators

2018-12-14 Thread fgergo
Could you please give 2 examples, where the results depend on the
precedence? Maybe on play.golang.org ?
Maybe this also helps: https://golang.org/ref/spec#Operators

On 12/14/18, 伊藤和也  wrote:
> Can I say the precedence of paretheses are lower than unary operators and
> higher than binary operators.
> unary operators  (high)
>   ↑
>   parentheses ↑
> ↑
> binary operators  (low)
>
> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-nuts+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] Presidence of Operators

2018-12-14 Thread Jan Mercl
On Fri, Dec 14, 2018 at 7:45 AM 伊藤和也  wrote:

> Can I say the precedence of paretheses are lower than unary operators and
higher than binary operators.

As parenthesis are not operators they have no operator precedence. But see:
https://golang.org/ref/spec#Order_of_evaluation


Explicit parentheses affect the evaluation by overriding the default
associativity. In the expression x + (y + z) the addition y + z is
performed before adding x.


-- 

-j

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] Presidence of Operators

2018-12-13 Thread 伊藤和也
Can I say the precedence of paretheses are lower than unary operators and 
higher than binary operators. 
unary operators  (high)
  ↑
  parentheses ↑
↑ 
binary operators  (low)

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.