On Tue, 10 Feb 2009 17:14:00 +0300, Don <nos...@nospam.com> wrote:

Derek Parnell wrote:
On Tue, 10 Feb 2009 13:08:03 +0100, Don wrote:

A&&B is not so terrible, since you can do it by nesting, as above.
The big problem is A || B. It creates a mess.
 version(A) version = AorB;
version(B) version = AorB;
version(AorB) {
  . . .
}

Yes. And that sucks, because you've got the version statement in two places. And you've had to create an essentially meaningless temporary. [1] Then when you have a more complex expression, especially where A and B appear more than once, it gets disgusting.


[1] I know Walter's idea is that you create meaningful identifiers, but in practice this kind of versioning can be a workaround. EG B is "everything except WindowsME".

Version has so many shortcomings that it should definitely be redesigned.

My biggest complaint is that code inside version () {} block should be semantically correct. It creates many obstacles and disallows good use-cases: - you cannot mix D1, D2 and (in future) D3 in a single source code file without helf of mixins. - you cannot mix asm for different platforms in one source code file (because DMD doesn't understand ARM assembly, for instance)
- etc

Other use-case I came across recently reading .NET Framework source code:

class String :
   IFoo,
   IBar,
   IBaz,
#if SUPPORT_GENERICS
   IComparable<Foo>,
#endif
   IWhee
{
   // *very* large amount of code
}

How would you port it to D without code duplication and meaningless intermediate classes?

Reply via email to