18 ms·
That example of aliasing - is it possible to write such thing in Go? Will Go compiler eat it or will not compile? Just interesting, how Go behaves in compariso
by EugeneOZ 12y ago
That example of aliasing - is it possible to write such thing in Go? Will Go compiler eat it or will not compile? Just interesting, how Go behaves in comparison to Rust, as another modern language.
- Shoop 12y agoGo uses garbage collection, not ownership and borrowing.
- shadowmint 12y agoYou can have aliasing pointers in go; see https://gobyexample.com/mutexes https://gobyexample.com/mutexes for how you have to explicitly lock to update the target without undefined behaviour. However, since it's a GC, it's probably not possible to have a pointer that refers to a memory location that doesn't exist, because having a pointer to a memory location is by definition what keeps it from being free'd by the GC.
- EugeneOZ 12y agothanks. but time between 2 lines of code can be not enough for GC to be called to free first address. Maybe they just control it on language level.