Re: Using enum constant from different modules

2014-07-10 Thread Jacob Carlborg via Digitalmars-d-learn
On 10/07/14 23:48, "Marc Schütz" " wrote: Try other immutable variables (int arrays, structs), and non-immutable ones. They will probably behave differently. String literals are put directly in the executable and therefore should be the same. Array literals are dynamically allocated. -- /Ja

Re: Using enum constant from different modules

2014-07-10 Thread Jacob Carlborg via Digitalmars-d-learn
On 10/07/14 22:48, anonymous wrote: I don't think this is a bug. Remember that enums have copy-paste semantics. So, this is the same as comparing literals from different modules. Apparently, in the same module, a duplicate string literal is optimized out. But that's not done across the module b

Re: Using enum constant from different modules

2014-07-10 Thread Jacob Carlborg via Digitalmars-d-learn
On 10/07/14 22:47, "Marc Schütz" " 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 thi

Re: Using enum constant from different modules

2014-07-10 Thread simendsjo via Digitalmars-d-learn
On 07/11/2014 01:08 AM, sigod wrote: > On Thursday, 10 July 2014 at 20:59:17 UTC, simendsjo wrote: >> Strings behaves a bit odd with is(). The following passes: >> >> import std.stdio; >> void f(string a, string b) { >> assert(a is b); // also true >> } >> void main() { >> string a = "aoeu"

Re: Using enum constant from different modules

2014-07-10 Thread sigod via Digitalmars-d-learn
On Thursday, 10 July 2014 at 20:59:17 UTC, simendsjo wrote: Strings behaves a bit odd with is(). The following passes: import std.stdio; void f(string a, string b) { assert(a is b); // also true } void main() { string a = "aoeu"; string b = "aoeu"; assert(a is b); // true f(a

Re: Using enum constant from different modules

2014-07-10 Thread via Digitalmars-d-learn
On Thursday, 10 July 2014 at 20:59:17 UTC, simendsjo wrote: Strings behaves a bit odd with is(). The following passes: import std.stdio; void f(string a, string b) { assert(a is b); // also true } void main() { string a = "aoeu"; string b = "aoeu"; assert(a is b); // true f(a

Re: Using enum constant from different modules

2014-07-10 Thread simendsjo via Digitalmars-d-learn
On 07/10/2014 10:47 PM, "Marc Schütz" " wrote: > On Thursday, 10 July 2014 at 20:27:39 UTC, Jacob Carlborg wrote: >> Here's a code example: >> >> module main; >> >> import foo; >> >> enum Get = "GET"; >> >> void bar (string a) >> { >> assert(a is Get); >> } >> >> void main () >> { >> asd();

Re: Using enum constant from different modules

2014-07-10 Thread anonymous via Digitalmars-d-learn
On Thursday, 10 July 2014 at 20:27:39 UTC, Jacob Carlborg wrote: Here's a code example: module main; import foo; enum Get = "GET"; void bar (string a) { assert(a is Get); } void main () { asd(); } module foo; import main; void asd() { bar(Get); } Running the above code will c

Re: Using enum constant from different modules

2014-07-10 Thread via Digitalmars-d-learn
On Thursday, 10 July 2014 at 20:27:39 UTC, Jacob Carlborg wrote: Here's a code example: module main; import foo; enum Get = "GET"; void bar (string a) { assert(a is Get); } void main () { asd(); } module foo; import main; void asd() { bar(Get); } Running the above code will c