Improving version(...)
Jonathan M Davis
jmdavisProg at gmx.com
Tue Oct 19 15:35:50 PDT 2010
On Monday, October 18, 2010 12:24:48 Don wrote:
> And currently, you can make a typo like:
> version(Linix) {}
> and it compiles happily. I don't like that. Especially when we have
> builtin names like D_Inline_Asm_X86_64!
The real question is how to cleanly fix that. A version is defined only if it's in
use, so it can't do like variable declarations do and complain that the version
wasn't declared. You could even be stupid enough to declare your own version
D_Inline_Asm_X86_65, so it's not even like the compiler can necessarily complain
when a version declaration uses a version which is almost the same as a correct
one but not quite (since you could just not be compiling with that version
declared at the moment).
So, while I agree that the current situation with versions and mispelling them
is problematic, I haven't a clue how you'd fix it right now. If _all_ versions
had to be declared and then only the enabled ones were compiled in, _then_ we
could make it work, since the entire list of versions would be known, but that
would be a definite departure from how things work now and would likely make it
very hard to do version = otherVersion; in your code like you can do now.
- Jonathan M Davis
More information about the Digitalmars-d
mailing list