--
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...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/ba7b2c95-829b-4da4-916a-d53a06ec3428n%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/d763c1fd-6e57-41f1-90e1-98a369ddf3bcn%40googlegroups.com.
For simple scenarios, compiler optimizations might be possible.But for some complicate ones, it is hard for compiler to do optimizations.For example, the element is modified by an function between the mapelement getter and setter and the behavior of the function is hard todetermined at compile time, it might modify or not modify the key.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/52f00985-3e0b-4562-80d9-705ae8e5e507n%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CAEkBMfEggD%2BnqVJFismVYK%3DqtviFozVft1jdBuT7-VM8cgxXZQ%40mail.gmail.com.
For simple scenarios, compiler optimizations might be possible.But for some complicate ones, it is hard for compiler to do optimizations.For example, the element is modified by an function between the mapelement getter and setter and the behavior of the function is hard todetermined at compile time, it might modify or not modify the key.Yes. I would strongly prefer to have these uncommon cases be slower to complicating the language.FWIW, if anything, the signature would have to take a `func(T) T`, not a `func(*T)` - values in a map are not addressable for a reason. If we would use a pointer, it would allow the programmer to retain that pointer outside of the function, which would not be safe.
Isn't this really just another form of issue 3117?
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/8193fa0b-307f-421e-a2f8-a7e2f23777b5n%40googlegroups.com.
On Mar 17, 2021, at 4:23 PM, Matthew Holiday <matthew...@nytimes.com> wrote:
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CAGSa1CnPs3jnx07P23rzxKfCjDR0Bq580-k3Gxy0Zj1%3Dqo9dng%40mail.gmail.com.