www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - version bug? or am I missing something?

reply "clone!(all)" <no spam.com> writes:
The following outputs "Unicode!". If I reverse the comment for [1] and 
[2] however, the output is "ASCII".

file a:
================================
module A;

version = Unicode;  [1]

version(Unicode)
{
	alias ChoiceA Choice;
}
else
{
	alias ChoiceB Choice;
}

string ChoiceA() { return "Unicode!"; }

string ChoiceB() { return "ASCII"; }


file b:
================================
module B;

import std.stdio: writeln;
import A;

//version = Unicode; [2]

static this()
{
	writeln(Choice());
}

void main(){}


==========
experience = GetExperience();
assert(experience == "tyro")
Jun 28 2011
parent reply Jonathan M Davis <jmdavisProg gmx.com> writes:
On 2011-06-28 19:22, clone!(all) wrote:
 The following outputs "Unicode!". If I reverse the comment for [1] and
 [2] however, the output is "ASCII".
 
 file a:
 ================================
 module A;
 
 version = Unicode;  [1]
 
 version(Unicode)
 {
 	alias ChoiceA Choice;
 }
 else
 {
 	alias ChoiceB Choice;
 }
 
 string ChoiceA() { return "Unicode!"; }
 
 string ChoiceB() { return "ASCII"; }
 
 
 file b:
 ================================
 module B;
 
 import std.stdio: writeln;
 import A;
 
 //version = Unicode; [2]
 
 static this()
 {
 	writeln(Choice());
 }
 
 void main(){}
 
 
 ==========
 experience = GetExperience();
 assert(experience == "tyro")
When you use use add a new version like that, it only affects the file that it's in. No other files are affected. If you want it to affect all files, you have to use the -version flag when compiling. - Jonathan M Davis
Jun 28 2011
parent "clone!(all)" <no spam.com> writes:
On 6/29/2011 11:28 AM, Jonathan M Davis wrote:
 On 2011-06-28 19:22, clone!(all) wrote:
 The following outputs "Unicode!". If I reverse the comment for [1] and
 [2] however, the output is "ASCII".

 file a:
 ================================
 module A;

 version = Unicode;  [1]

 version(Unicode)
 {
 	alias ChoiceA Choice;
 }
 else
 {
 	alias ChoiceB Choice;
 }

 string ChoiceA() { return "Unicode!"; }

 string ChoiceB() { return "ASCII"; }


 file b:
 ================================
 module B;

 import std.stdio: writeln;
 import A;

 //version = Unicode; [2]

 static this()
 {
 	writeln(Choice());
 }

 void main(){}


 ==========
 experience = GetExperience();
 assert(experience == "tyro")
When you use use add a new version like that, it only affects the file that it's in. No other files are affected. If you want it to affect all files, you have to use the -version flag when compiling. - Jonathan M Davis
Got it... thank for the swift response.
Jun 28 2011