I think that could also work. I prefer keeping that same syntax for regular strings (the square-brackets make things easier to read). I'm assuming strings don't normally return views because their contents could change, thus copies are safer. That's why I'm suggesting creating an 'ImmutableString' type. That way you know the contents won't change, and returning a view should always be the safe thing to do.
On Wednesday, June 11, 2014 9:45:35 AM UTC-4, [email protected] wrote: > > Hi Abe, >> >> Looks like you just reimplemented SubString. >> >> julia> x = "Hi there!" >> "Hi there!" >> >> julia> SubString(x, 2, 4) >> "i t" >> >> julia> typeof(ans) >> SubString{ASCIIString} (constructor with 1 method) >> >> >> Which is totally understandable, as there seems to be almost zero >> documentation about them. Would you mind opening an issue about that? >> > > Hi both of you. > > Wouldn't it be logical also to have "sub" handle Strings as it does for > arrays? > > julia> sub([1,2,3,4,5,6], 1:2) > 2-element SubArray{Int64,1,Array{Int64,1},(UnitRange{Int64},)}: > 1 > 2 > > and maybe call it "view" instead of or in addition to "sub"? > >
