Using enum constant from different modules
Jacob Carlborg via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Thu Jul 10 23:11:53 PDT 2014
On 10/07/14 22:47, "Marc Schütz" <schuetzm at gmx.net>" wrote:
> No, this is equivalent to:
>
> void bar (string a)
> {
> assert(a is "GET");
> }
>
> void asd()
> {
> bar("GET");
> }
>
> Enums behave as if their values are copy-n-pasted everywhere they are
> used (you probably know that).
Yes, I was thinking that. Then I was thinking string literals are put
directly in the executable and then I got confused about it behaving
differently in out in a separate module.
> The compiler probably conflates the two identical strings when they're
> in the same module. This is safe for immutable data. I'm sure there's
> something in the spec about it...
Sounds reasonable.
--
/Jacob Carlborg
More information about the Digitalmars-d-learn
mailing list