On 05/09/12 21:13, Patrick Walton wrote:
On 9/5/12 1:10 PM, Gareth Smith wrote:
How about having str be represented internally - but not in the type
system - as a pointer to the actual string data. Copying a str would
copy the pointed-to string data in addition to the pointer, so str would
not be implicitly copyable.

Where would the contents be stored?

On the the non-task-local (AKA shared?) heap.


Graydon wrote:
>> Is this actually a reasonable system?
> That's what they used to be. People passed them by-value too much and we made too many copies, and balked at the double-indirection implied by passing around an &str or such.

I was one of those passing them by value too much. I did it because it seemed like the idiomatic thing to do. Even rustc did it - that made it seem legit. It no longer seems like the idiomatic thing to do because the compiler emits a warning about it unless it is done explicitly, so I try to avoid it. I think that documentation and compiler warnings will determine typical use.

> That also doesn't handle the fixed-size, constant-memory and substring-slice use-cases.

Fair enough.

> The current scheme is a very delicate balance between a large number of pressures; I think it's about the best we're going to get.

The problem with rust's strings is that any rust program I write seems to be more complicated because of features that strings have that 99% of the time I will not use. I have to pay for safe concurrency even though it looks like I will barely be using it. Ditto with fixed size and constant memory strings.

You created a nice language for programs that are mostly non-concurrent (regardless of how nice it is for highly concurrent programs), so I and others are going to try using it for that :) ... and sometimes wondering why the strings are so hard to use.

I don't know what the fix is, but I think this issue is going to keep coming up, because I think *for some people* there is a better balance to be had.

Thanks
Gareth
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to