Re: [go-nuts] testing whether two maps are the same object

2023-07-19 Thread 'Axel Wagner' via golang-nuts
On Tue, Jul 18, 2023 at 5:22 PM Jochen Voss wrote: > Dear Jason, > > Thanks for the idea of using reflect. Do you know whether > `reflect.ValueOf(a).UnsafePointer()` is somehow "safer" than > `*(*uintptr)(unsafe.Pointer(&a))`? > For what it's worth: I'd argue comparing `reflect.ValueOf(a).Unsaf

Re: [go-nuts] testing whether two maps are the same object

2023-07-18 Thread Jochen Voss
Dear Jason, Thanks for the idea of using reflect. Do you know whether `reflect.ValueOf(a).UnsafePointer()` is somehow "safer" than `*(*uintptr)(unsafe.Pointer(&a))`? reflect.DeepEqual will not work, since it just compares contents of the maps: https://go.dev/play/p/tE_qZI2cKEd All the best,

Re: [go-nuts] testing whether two maps are the same object

2023-07-18 Thread Jason Phillips
You can also use the reflect package rather than (directly) reaching for unsafe. The reflect.DeepEqual function does something along the lines of: https://go.dev/play/p/IVt0Z-mxugh On Tuesday, July 18, 2023 at 10:45:18 AM UTC-4 Jan Mercl wrote: > On Tue, Jul 18, 2023 at 4:35 PM Jochen Voss wro

Re: [go-nuts] testing whether two maps are the same object

2023-07-18 Thread Jan Mercl
On Tue, Jul 18, 2023 at 4:35 PM Jochen Voss wrote: > Is there a better way? I have never been here and please don't do this: https://go.dev/play/p/x4QYJubXMnQ -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and s

[go-nuts] testing whether two maps are the same object

2023-07-18 Thread Jochen Voss
Dear all, To implement the "eq" operator in a simple PostScript interpreter, I need to determine whether two maps are the same object. This can be done by adding a new element to one map, and checking whether the new entry also appears in the second map, but as you can imagine, the resulting c