Am Freitag, 1. März 2013 21:01:09 UTC+1 schrieb minux:

On Sat, Mar 2, 2013 at 3:51 AM, Robert Clausecker <fuz...@gmail.com<javascript:>
Actually, as with all the other operators I expect foo &&= bar to have
the same effect as tmp := foo ; foo = tmp && bar, ie. bar is not always
evaluated. This makes sense as it is coherent to all other assignment
operators; they all can be rewritten this way.
but that violate the short circuit property of && and ||.

some people will think this way:
a &&= f()

it will virtually translate into:
a = a && f()

so it is really:
if a {
a = f()
That's exactly the behavior my code checks. If Go supported & for bool, the
following would be equal

tmp = a && b
if (a) { tmp = a; } else { tmp = b; }

So, in a statement a &&= b which evaluates to a = a && b (except that a is
evaluated exactly once), the following two statements are equal

a &&= b
if (a) { a = b; } else { a = false; }

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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

Discussion Posts


Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 8 of 21 | next ›
Discussion Overview
groupgolang-nuts @
postedMar 1, '13 at 7:02p
activeMar 3, '13 at 2:38a



site design / logo © 2022 Grokbase