On Sat, Jan 17, 2009 at 6:26 AM, Yigal Chripun <[email protected]> wrote: > bearophile wrote: >> >> Bill Baxter: >>> >>> To me it's hard to see those variable declarations as being anything >>> other than scoped to the blocks they're in. >>> So all I'm saying is if we could have some different delimiters for >>> non-scope blocks then it might be nice, and make it easier to see when >>> scopes are ending and when they are not. >> >> *Now* I understand, and I see your point. >> It's the usual problem: ASCII doesn't have enough ways to represent >> containers and delimiters :-) >> >> So if this is your original code (I have improved your indentations and >> improved readability a little): >> >> [...] >> >> I don't think lot of people will appreciate those. >> So the lack of different block delimiters may make this problem have no >> better solution. >> >> Bye, >> bearophile > > in C# they use the same syntax as the c pre-processor for conditional > compilation and such even though C# doesn't have a pre-processor and the > syntax is interpreted by the compiler. the above would be something like: > > void doSomething(T)(int i) { > if (i == 0) { > #if (is(T == A)) > A.SomeAlias x; > #elif (is(T == B)) > B.SubType x; > #else > T x; > #endif > > x = ... whatever > } > else > int y = x; > } > > D can always revert to this kind of syntax for compile time code.
I kinda like that, actually, but I doubt it'll be very popular around here. --bb
