Closed
Description
opened on Oct 28, 2017
Consider the following code:
s = "123"
v = Vector{UInt8}(s)
Now changing v
mutates s
.
Since strings should be immutable I would it find it more natural to:
- define
reinterpret(UInt8, s::String)
that would perform such in-place conversion (as this is what one would expect fromreinterpret
); - make
convert(Vector{UInt8}, s::String)
allocate a new vector (so that users do not accidentally mutate strings).
Additionally this would be consistent with the general behavior that Vector{UInt8}(s)
for AbstractString
other than String
would create a copy.
A non-breaking alternative would be to add an information to the documentation that this conversion is in-place.
Activity