On Thu, May 17, 2012 at 1:50 AM, Bennie Kloosteman <[email protected]>wrote:
> In the context of unsafe I thought people might find this interesting...
>
> I have been looking at C# strings and its quite obvious that what they
> really wanted was a value type ( for performance reasons) that is
> normally passed by reference...
I don't think they wanted a value type. As you say, they wanted it to be
passed by reference (and also immutable), so that's a reference (boxed)
type. What I do think (and what I suspect you meant) is that they did not
want to accept the *additional* indirection that is often present in vector
implementations, where the "C" rendition of the structure looks something
like:
struct VectorOfFoo {
int length; // fixed at creation
Foo* vectorPayload;
};
The reason for the added indirection mainly has to do with the
runtime-level implementation of larger objects - it ensures that there is
exactly one live reference to the payload data, which makes compacting
BigSpace easier.
Once we get beyond that issue, the main reason to distinguish String from
array<UniChar> has to do with (a) some semantics distinctions, and (b)
encapsulating internal decisions about string encoding.
This is actually a good example of a place where having a Nat kind helps.
_______________________________________________
bitc-dev mailing list
[email protected]
http://www.coyotos.org/mailman/listinfo/bitc-dev