I also wanted this (when I was learning Go I just assumed & would work in front of any expression, including function calls). I opened proposal https://github.com/golang/go/issues/22647 where there was some discussion, and further discussion over at https://github.com/golang/go/issues/9097, which is still open.
The TLDR is: * Allowing taking the address of arbitrary expressions like &"foo" and &(1+2) is probably a bad idea * Using the syntax &T(V), e.g., &int64(v), is a reasonable idea and might have a chance * Generics would allow a generic addr.P() function to take the address of an arbitrary value, making this unnecessary -Ben On Tuesday, April 14, 2020 at 11:50:58 PM UTC+12, viktor...@gmail.com wrote: > > Hi, > > What is the reason for not allowing taking the address of a function > return value, ie having to assign it to a variable first? > > See https://play.golang.org/p/rjLwiVmikMc > > Regards -- 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. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/3e6dcc81-9ecc-46f5-82d1-bb114fcdb403%40googlegroups.com.