Defining constant values in struct

ketmar via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Jun 17 10:47:02 PDT 2015


On Wed, 17 Jun 2015 09:49:56 +0900, Mike Parker wrote:

> On 6/17/2015 6:17 AM, tcak wrote:
>> As far as I known, when I define a string with enum and it is used at
>> different parts of code, that string is repeated again and again in
>> executable file instead of passing a pointer to string. So, using enum
>> with string doesn't seem like a good idea.
>>
> The string is not repeated again and again in the *executable*. The
> compiler is smart enough to recognize the same string is used in
> multiple places. It will be placed in the data segment only once. It's
> no different than using a string literal.

but only to some extent[1].

[1] https://issues.dlang.org/show_bug.cgi?id=14459
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20150617/90ac702c/attachment.sig>


More information about the Digitalmars-d-learn mailing list