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

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


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.



More information about the Digitalmars-d mailing list