Why is Exceptions c'tor this(immutable(char[]) instead of const(char[]) ?

Steven Schveighoffer schveiguy at yahoo.com
Thu Aug 26 13:16:14 PDT 2010

On Thu, 26 Aug 2010 16:05:00 -0400, Mathias Laurenz Baumann  
<anonym001 at supradigital.org> wrote:

> Well, topic says it all. Why is the string parameter for the Exception  
> class in object.di an immutable(char[])?
> A const(char[]) works for both, immutable(char[]) types and char[]  
> types. why this limitation?

Normally, I'd agree with you, but if the exception gets a  
immutable(char)[], it can store it without duplication, and without worry  
it will change it.

If you passed in a const, then you'd *have* to duplicate it.

If you have a char[] or a const(char)[] that you want to pass in, call  
idup on it.


More information about the Digitalmars-d mailing list