digitalmars.D - C like macro is useful
- davidl <davidl 126.com> Jul 23 2008
- downs <default_357-line yahoo.de> Jul 23 2008
- "Jarrett Billingsley" <kb3ctd2 yahoo.com> Jul 23 2008
consider:
version(v1)
{
enum e
{
a,
b
}
}
else
{
enum e
{
a,
b,
c
}
}
If my enum contains a lot of stuffs.... D version becomes a disaster.
consider:
version(v1)
{
if ( cond1() && cond2() && a==b)
{
//blah
}
}
else
{
if ( cond1() && cond2() && a!=b)
{
//blah
}
}
in C you can do it
if ( cond1() && cond2() &&
#ifdef v1
a==b
#else
a!=b
#endif
)
{
// blah
}
Any good and practical way to solve these?
--
使用 Opera 革命性的电子邮件客户程序: http://www.opera.com/mail/
Jul 23 2008
davidl wrote:consider: version(v1) { enum e { a, b } } else { enum e { a, b, c } } If my enum contains a lot of stuffs.... D version becomes a disaster. consider: version(v1) { if ( cond1() && cond2() && a==b) { //blah } } else { if ( cond1() && cond2() && a!=b) { //blah } } in C you can do it if ( cond1() && cond2() && #ifdef v1 a==b #else a!=b #endif ) { // blah } Any good and practical way to solve these?
version(v1) auto cond = a == b; else auto cond = a != b; What's the problem again?
Jul 23 2008
"downs" <default_357-line yahoo.de> wrote in message news:g67bqp$20ma$2 digitalmars.com...version(v1) auto cond = a == b; else auto cond = a != b; What's the problem again?
That's one solution for one case. It does not hold up in the general case. How about the enum example? How about differing declarations in general? How about trying to make class invariants work in both D1 and D2?
Jul 23 2008








"Jarrett Billingsley" <kb3ctd2 yahoo.com>