Using julia v0.6.4
I was trying to convert String to bytes and add it to a buffer. I noticed the following
a = “temp”
b = Vector{UInt8}(a)
b[1] += 1
This ends up modifying a. Shouldn’t a call to Vector create new underlying memory? What happens if a goes out of scope now?
c = String(b)
b[1] += 1
Again, c in modified. This means c also shares the underlying data. If I now apply shift! on b, what happens to the memory of c? This behavior seems similar to reinterpret for arrays, although there shift! is forbidden and one is greeted with an error, cannot resize array with shared data. Should this not behave similarly?
Please suggest proper way to handle these conversions.
Thank you