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

monarch_dodra monarchdodra at gmail.com
Fri Aug 2 04:27:47 PDT 2013


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.


More information about the Digitalmars-d mailing list