One way to deal with transient ranges & char[] buffers

Tobias Pankrath tobias at pankrath.net
Fri Aug 2 04:44:22 PDT 2013


On Friday, 2 August 2013 at 11:27:48 UTC, monarch_dodra wrote:
> On Friday, 2 August 2013 at 11:19:05 UTC, Tobias Pankrath wrote:
>> On Friday, 2 August 2013 at 08:46:18 UTC, monarch_dodra wrote:
>>>
>>> Without doing this, you face the eternal problem: Should I 
>>> return a "string", to give my end user more guarantees, when 
>>> in fact my char array is perfectly mutable, or should I 
>>> return a char[], forcing my end user to make an idup(or an 
>>> unsafe cast) if he actually needed a string?
>>>
>>> It's a tough problem to tackle.
>>
>> The solution has been posted to this newsgroup already in form 
>> of unique/unaliased types. Thats THE selling point for them.
>>
>> If you have an array of char and it could be char[] as well as 
>> string, than let the type system infer the right one for you.
>
> Interesting. Thanks for the tip. I'll look these up.

http://www.digitalmars.com/d/archives/digitalmars/D/Immutable_and_unique_in_C_180572.html


More information about the Digitalmars-d mailing list