On Monday, 19 August 2013 at 18:28:10 UTC, Ali Çehreli wrote:
On 08/19/2013 03:18 AM, Borislav Kosharov wrote:> So if I want to have a string constant it is a lot better to declare it as:
>
> static immutable string MY_STRING = "Some string";
>
> Because it won't be duplicated?

enum is fine with strings.

It is a common space optimization of the compilers not to duplicate identical strings. The following program includes just one "hello world" in the compiled object file:


And why can't this be done with any compile time objects? AA's that are identical be collated similar to strings.

Reply via email to