[Issue 11172] Allow scoped assignment of version and debug statements
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Oct 4 12:15:05 PDT 2013
http://d.puremagic.com/issues/show_bug.cgi?id=11172
--- Comment #2 from Andrej Mitrovic <andrej.mitrovich at gmail.com> 2013-10-04 12:15:03 PDT ---
(In reply to comment #1)
> They cannot be imported from other
> modules, and do not affect imported modules.
Right, but they can be set in the module itself:
-----
version = CALL_FOO; // active in this module only
void foo() { }
void main()
{
version (CALL_FOO)
{
foo();
}
}
-----
I was looking for a more fine-grained version of this. The reason why is that
two code fragments which are related to each other should also be closer to
each other (in this case CALL_FOO is only used inside a single function). In a
large module I could easily miss that a version switch was set.
Personally I dislike that version/debug statements are global to begin with.
It's only a matter of time before two libraries end up having two conflicting
notions of the same version/debug symbol.
For example if libFoo has a version(SharedLib) block, but libBar also uses this
same version block but for a completely different purpose you will end up
enabling the block for both libraries even if you only wanted to do it for a
single library.
It very much reminds me of a C macro. I guess you can close this, I can use
'static if' instead.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list