Re: [go-nuts] Evaluation order of return

2020-09-25 Thread Michael Jones
Another way to understand the general topic is by comparison to Lindenmayer systems. The compiler is an iterated rewrite framework and the exact code that you get can be a surprise the same way L-System graphics vary. On Thu, Sep 24, 2020 at 10:36 PM cs.ali...@gmail.com < cs.alikoyu...@gmail.com>

Re: [go-nuts] Evaluation order of return

2020-09-24 Thread cs.ali...@gmail.com
I understood perfectly now, thanks for the explanations and the link! I really appreciate you guys! On Thursday, September 24, 2020 at 3:28:10 AM UTC+3 Ian Lance Taylor wrote: > On Wed, Sep 23, 2020 at 1:10 AM cs.ali...@gmail.com > wrote: > > > > I am not actually questioning the current design

Re: [go-nuts] Evaluation order of return

2020-09-23 Thread Ian Lance Taylor
On Wed, Sep 23, 2020 at 1:10 AM cs.ali...@gmail.com wrote: > > I am not actually questioning the current design, as you both said it is not > a good practice to call a return statement as I wrote above, I am trying to > understand the relation between memory, interface and order of evaluation. I

Re: [go-nuts] Evaluation order of return

2020-09-23 Thread Jesper Louis Andersen
On Wed, Sep 23, 2020 at 10:09 AM cs.ali...@gmail.com < cs.alikoyu...@gmail.com> wrote: > Is there a paper that I can find why the compiler considers them for > ordering, why it is important for performance or anything else? > > A CPU has a limit to how many load/store instructions it can issue in

Re: [go-nuts] Evaluation order of return

2020-09-23 Thread cs.ali...@gmail.com
Thanks Axel, Ian! I am not actually questioning the current design, as you both said it is not a good practice to call a return statement as I wrote above, I am trying to understand the relation between memory, interface and order of evaluation. It is clear that the compiler takes account of wh

Re: [go-nuts] Evaluation order of return

2020-09-21 Thread Ian Lance Taylor
On Mon, Sep 21, 2020 at 9:34 AM 'Axel Wagner' via golang-nuts wrote: > > The evaluation order is defined here: > https://golang.org/ref/spec#Order_of_evaluation > The important part is that the order of evaluation in a return statement is > only defined for function calls, method calls and commun

Re: [go-nuts] Evaluation order of return

2020-09-21 Thread 'Axel Wagner' via golang-nuts
The evaluation order is defined here: https://golang.org/ref/spec#Order_of_evaluation The important part is that the order of evaluation in a return statement is only defined for function calls, method calls and communication statements, but not in relation to other operations. So, in return intNum

[go-nuts] Evaluation order of return

2020-09-21 Thread cs.ali...@gmail.com
Why does the compiler change evaluation order of return when adding a new field to a struct? I didn't check the compiler output, I only guess it somehow changes the order. play package main import ( "fmt" ) type Number interface { Value() int } type Integ

[go-nuts] Evaluation order

2016-12-13 Thread Dave Cheney
The order of evaluation is not specified. We found a few years ago that gccgo and gc differed in this respect and _both_ implantations are correct. https://dave.cheney.net/2013/11/15/evaluation-order-oddity -- You received this message because you are subscribed to the Google Groups "golang-n

Re: [go-nuts] Evaluation order

2016-12-13 Thread Ian Lance Taylor
On Tue, Dec 13, 2016 at 6:46 AM, Jesper Louis Andersen wrote: > On Tue, Dec 13, 2016 at 2:57 PM Rafał Jęczalik > wrote: >> >> Hey Gophers! >> >> Does the spec guarantees the following program will always output "3 2"? >> > > Yes. f() is in funcall context, and there the order is lexicographic > l

Re: [go-nuts] Evaluation order

2016-12-13 Thread Jesper Louis Andersen
On Tue, Dec 13, 2016 at 2:57 PM Rafał Jęczalik wrote: > Hey Gophers! > > Does the spec guarantees the following program will always output "3 2"? > > Yes. f() is in funcall context, and there the order is lexicographic left-to-right as the specification says. -- You received this message becaus

[go-nuts] Evaluation order

2016-12-13 Thread Rafał Jęczalik
Hey Gophers! Does the spec guarantees the following program will always output "3 2"? https://play.golang.org/p/InTOwJIPmD >From what I read [0] only evaluation order of expressions inside slice or map definitions or indexing on those values is unspecified? -- Rafal [0] https://golang.org/ref