* [email protected] <[email protected]> [260717 09:45]:
> Hi all,
> 
> So, given following code:
[snip]
> func TestNumAdd(t *testing.T) {
>     n := Num(10)
>     a, b, c := n, n.add(1), n.add(2)
>     // a, b, c := n.get(), n.add(1).get(), n.add(2).get()
>     fmt.Println(a, b, c)
> }
> 
> What do you think the `TestNumAdd` function will output?

The Go Language Specification is very explicit about this:

    https://go.dev/ref/spec#Order_of_evaluation

See the explanation under the first example:

    > However, the order of those events compared to the evaluation and
    > indexing of x and the evaluation of y and z is not specified,
    > except as required lexically.

So, all function calls (n.add()) happen in left-to-right order, but when
they are evaluated relative to the evaluation of simple variables (n in
this case) is explicitly unspecified.

> PS. I also asked Gemini the same question above, and it was also confused. 

What did you expect from an LLM?  It only knows what other people have
told it, and even then it has a hard time telling when it has been told
the truth or a falsehood.

...Marvin

-- 
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 [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/golang-nuts/alpQrHpU%2BxtRR84J%40basil.wdw.

Reply via email to