www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - version system: query-change lock idea

reply =?UTF-8?B?VGhvbWFzIEvDvGhuZQ==?= writes:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

The current version/debug system has some undefined/unenforced corners.

#--- sample 1 ---
version(A){
	pragma(msg, "everytime");
}else{
	version=A;
}
#------

The "everytime" message will always be displayed.


#--- sample 2 ----
version=A;

version(A){
	version=B;
}

version(B){
	pragma(msg, "sometimes");
}
#------

#--- sample 3 ----
version(A){
	version=B;
}

version=A;

version(B){
	pragma(msg, "sometimes");
}
#------

The content of sample 3 is a reordered sample 2.
Sample 2 displays the message whereas sample 3 displays nothing.


I suggest a query-change lock mechanism to close those corners.

The compiler has to ensure that re-evaluating a conditional -
"version(A)" - will always have the same result.

#--- sample 4 ---
version(A){
	pragma(msg, "A: true");
}
version=A; // ***illegal, the status of A was changed***
#------


#--- sample 5 ---
version=A;
version(A){
	pragma(msg, "A: true");
}
version=A; // ***legal, the status of A didn't change ***
#------


#--- sample 6 ---
version=2;
version(2){
	pragma(msg, "level >= 2");
}
version=3; // ***legal***
#------
true: newLevel >= highestQuery
true: highestQuery >= current level


#--- sample 7 ---
version=1;
version(2){
	pragma(msg, "level >= 2");
}
version=3; // ***illegal***
#------
true: newLevel >= highestQuery
false: highestQuery >= currentLevel


#--- sample 8 ---
version=1;
version(2){
	pragma(msg, "level >= 2");
}
version=0; // ***illegal***
#------
false: newLevel >= highestQuery
true: highestQuery >= currentLevel


Thomas
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (MingW32)

iD8DBQFChkio3w+/yD4P9tIRAoCvAKCwFPw5SrEpAc0XXaq6yyU76Gy1GQCgpMrs
M0sLKyNIqWi1iIEQ0G3qizE=
=r5pg
-----END PGP SIGNATURE-----
May 14 2005
parent "Walter" <newshound digitalmars.com> writes:
Yeah, I was thinking that too. You're right.
May 14 2005