The GC optimization idea is a nice one because then we only optimize
depending on the amount of memory pressure.
>>Are you considering a similar hack to .NET where the root char[] is
internal and not a separate object ?
>I'm not sure what you are referring to, so probably not. BitC char is
simply a scalar type. It isn't an object.
In .NET while a char is scalar a char array is a object but can with Marshal
tricks embed the array directly into an object ( since you know the size
before hand and strings are immuable) . So new string ("x") only creates a
single object ( Not a string and an internal array object). This is very
useful for small strings.
>> The fact you suggested flags on the array seems to suggest it rather
than typeof() this is worth it as it means your only creating 1 object
instead of 2 .
> I'm sorry - I'm not understanding what you are saying here. Can you expand
on this?
William was suggesting you may use the type information to determine the
type of the strand on the fly eg typeof() implying the arrays are objects.
>The NoHeap issue is actually very complicated, and the current C# answer
isn't very good. One problem with stranded strings is that it's a bit
strange to ask what it means to pin them.
Agree , C# has come close for the higher level GC languages but it's a
tricky problem which MS thought too difficult hence only half hearted value
types in C# which 99.9% of C# devs struggle to use well. Why is pinning
them strange ? Especially for a compacting collector basically all strands
are pinned , or are you referring to legacy C habits and coders. In C# for
interop there is a trick here
Eg
string value = string.Empty;
// Use fixed statement on a char pointer.
fixed (ch* ptr = value)
As you stated this would not be possible with Stranded strings , nor does
it make sense since for interop you will need a fixed encoding of a single
string . It would have to be
StrandedString value = StrandedString.Empty;
Fixed ( char* pointer = value. GetUTF16String)
Which would not be fast as it would need a copy and possible encoding .
Note.NET makes strings mutable to external processes by exposing its
internal array.this hack may be done for performance reasons and it has the
advantage that most interop on windows use the same encoding it may also be
prompted by win32 using sysalloc to create a string which is then filled (
ie mutable API).
Ben
_______________________________________________
bitc-dev mailing list
[email protected]
http://www.coyotos.org/mailman/listinfo/bitc-dev