Posts

Showing posts from March 25, 2019

Aliasing of slices

Image
2 1 How to check whether two slices are backed up by the same array? For example: a := int1, 2, 3 b := a[0:1] c := a[2:3] alias(b, c) == true How should alias look like? arrays pointers go memory slice share | improve this question edited Nov 13 '18 at 12:18 icza 175k 25 353 383 asked Nov 13 '18 at 11:47 Ecir Hana Ecir Hana 3,975 10 42 87 1 You must compare the addresses of their elements. Check if the ranges overlap. – Volker Nov 13 '18 at 11:54 add a comment  |  2 1 How to check whether two slices are backed up by the same array? For example: a := int1, 2, 3 b := a[0:1] c := a[2:3] alias(b, c) == true How should alias look like? arrays pointers go memory slice share | improve this question edited Nov 13 '18 at 12:18 icza 175k 25 353 383 asked Nov 13 '18 at 11:47 Ecir Hana Ecir Hana 3,975 10 42 87 1 You must compar