digitalmars.D.learn - version(debug)
- denizzzka (9/9) Oct 06 2012 Why
- denizzzka (1/1) Oct 06 2012 huh, text should be from upper letter: Assert, Debug
- Jonathan M Davis (41/42) Oct 06 2012 No. Those are wrong. The code compiles, but those versions don't exist, ...
- =?UTF-8?B?QWxleCBSw7hubmUgUGV0ZXJzZW4=?= (7/49) Oct 06 2012 version (assert) is a very recent addition to the compiler and is not in...
- Jonathan M Davis (8/10) Oct 06 2012 Which would probably explain why it's not working for him, since presum=
- denizzzka (5/16) Oct 06 2012 I am on dmd 2.060
- Jonathan M Davis (24/28) Oct 06 2012 I wouldn't expect you to try either version(debug) or debug {} without s...
- denizzzka (6/52) Oct 07 2012 I've got a situation that debug information should be placed into
- Jonathan M Davis (6/10) Oct 07 2012 Which is fine. It's just that you need to realize that debug blocks are ...
- Andrej Mitrovic (2/5) Oct 06 2012 I think that must be a typo on the website. Use version(debug) instead.
- denizzzka (3/3) Oct 06 2012 Strange, when you write to the forum then you solve problem
- Andrej Mitrovic (2/4) Oct 06 2012 That happens to me all the time too. :)
- denizzzka (3/10) Oct 06 2012 No, debug also don't works. Debug and Assert works fine
- Andrej Mitrovic (7/8) Oct 06 2012 Oh right, I was thinking of this:
- Jonathan M Davis (5/7) Oct 06 2012 There isn't. It's just that it compiles because Debug isn't a keyword. T...
Why version(assert){ int i = 1; } else { int k = 1; } causes error: Error: identifier or integer expected, not assert ? This is bug or feature? http://dlang.org/version.html says what it is correct code, because "assert" in the list of "Predefined Version Identifiers" How I can solve this problem by other way?
Oct 06 2012
huh, text should be from upper letter: Assert, Debug
Oct 06 2012
On Saturday, October 06, 2012 20:02:13 denizzzka wrote:huh, text should be from upper letter: Assert, DebugNo. Those are wrong. The code compiles, but those versions don't exist, so they're not compiled in. A version(Assert) or version(Debug) block will never be compiled in unless you define those versions. version(assert) is correct. For instance, this prints "yes" without -release and "no" with -release: import std.stdio; void main() { version(assert) { writeln("yes"); } else { writeln("no"); } } I am not seeing a compilation error with your example. What version of the compiler are you using? Maybe version(assert) is new (I'd never heard of it before), and your compiler is too old. The only reason that you would see an error due to an invalid version identifier would be if it's a keyword which isn't valid as a version identifier (e.g. debug). The fact that the compiler doesn't know about a version identifier doesn't produce an error. That just means that that particular block of code isn't compiled in. And debug isn't a valid version. It's not even in the list. The correct thing to do is to a use a debug block. For instance, this code import std.stdio; void main() { debug { writeln("yes"); } else { writeln("no"); } } will print "yes" when you compile with -debug and "no" otherwise. - Jonathan M Davis
Oct 06 2012
On 06-10-2012 20:23, Jonathan M Davis wrote:On Saturday, October 06, 2012 20:02:13 denizzzka wrote:version (assert) is a very recent addition to the compiler and is not in 2.060. -- Alex Rønne Petersen alex lycus.org http://lycus.orghuh, text should be from upper letter: Assert, DebugNo. Those are wrong. The code compiles, but those versions don't exist, so they're not compiled in. A version(Assert) or version(Debug) block will never be compiled in unless you define those versions. version(assert) is correct. For instance, this prints "yes" without -release and "no" with -release: import std.stdio; void main() { version(assert) { writeln("yes"); } else { writeln("no"); } } I am not seeing a compilation error with your example. What version of the compiler are you using? Maybe version(assert) is new (I'd never heard of it before), and your compiler is too old. The only reason that you would see an error due to an invalid version identifier would be if it's a keyword which isn't valid as a version identifier (e.g. debug). The fact that the compiler doesn't know about a version identifier doesn't produce an error. That just means that that particular block of code isn't compiled in. And debug isn't a valid version. It's not even in the list. The correct thing to do is to a use a debug block. For instance, this code import std.stdio; void main() { debug { writeln("yes"); } else { writeln("no"); } } will print "yes" when you compile with -debug and "no" otherwise. - Jonathan M Davis
Oct 06 2012
On Saturday, October 06, 2012 20:42:01 Alex R=C3=B8nne Petersen wrote:version (assert) is a very recent addition to the compiler and is not=in2.060.Which would probably explain why it's not working for him, since presum= ably,=20 he's not building the compiler himself, but then it really shouldn't be= up on=20 the website yet. - Jonathan M Davis
Oct 06 2012
On Saturday, 6 October 2012 at 19:16:26 UTC, Jonathan M Davis wrote:On Saturday, October 06, 2012 20:42:01 Alex Rønne Petersen wrote:I am on dmd 2.060 debug {} else {} was not obvious for me - I thought that debug is a kind of qualifer.version (assert) is a very recent addition to the compiler and is not in 2.060.Which would probably explain why it's not working for him, since presumably, he's not building the compiler himself, but then it really shouldn't be up on the website yet. - Jonathan M Davis
Oct 06 2012
On Saturday, October 06, 2012 23:49:23 denizzzka wrote:I am on dmd 2.060 debug {} else {} was not obvious for me - I thought that debug is a kind of qualifer.I wouldn't expect you to try either version(debug) or debug {} without seeing them in the docs or in TDPL. I suppose that I can see why you would try version(debug), but it's not listed in the docs. There isn't really a debug version of anything in D. What debug {} does is it's compiled in when -debug is compiled in, and that can be used in conjunction with -release if you want to. So talking about debug vs release in D is likely to get very confusing. Rather -debug enables debug blocks which are intended for inserting debug code, _not_ code which is meant for non- release builds. It looks like version(assert) (which I guess is only in the github version right now) will effectively correspond to not having -release, but if there's ever a compiler flag which specifically enables or disables assertions instead of -release (which does more than just disable assertions - e.g. it disables bounds checking in non- safe code), then it won't actually be guaranteed to not be there if -release isn't there. It's close enough though I guess, particularly when the type of stuff that you specifically do in non-release code is typically the kind of stuff that you want done with assertions are enabled and probably wouldn't want enable if assertions were turned off, even if that were to somehow happen without -release. In any case, -debug and debug{} should be explained in the docs somewhere. It's certainly not the sort of thing that I would expect you to magically know. - Jonathan M Davis
Oct 06 2012
On Sunday, 7 October 2012 at 01:20:49 UTC, Jonathan M Davis wrote:On Saturday, October 06, 2012 23:49:23 denizzzka wrote:I've got a situation that debug information should be placed into the class via the constructor. Therefore, when used -debug constructor has another arguments list, and its need debug {} else {} for ctor calling.I am on dmd 2.060 debug {} else {} was not obvious for me - I thought that debug is a kind of qualifer.I wouldn't expect you to try either version(debug) or debug {} without seeing them in the docs or in TDPL. I suppose that I can see why you would try version(debug), but it's not listed in the docs. There isn't really a debug version of anything in D. What debug {} does is it's compiled in when -debug is compiled in, and that can be used in conjunction with -release if you want to. So talking about debug vs release in D is likely to get very confusing. Rather -debug enables debug blocks which are intended for inserting debug code, _not_ code which is meant for non- release builds. It looks like version(assert) (which I guess is only in the github version right now) will effectively correspond to not having -release, but if there's ever a compiler flag which specifically enables or disables assertions instead of -release (which does more than just disable assertions - e.g. it disables bounds checking in non- safe code), then it won't actually be guaranteed to not be there if -release isn't there. It's close enough though I guess, particularly when the type of stuff that you specifically do in non-release code is typically the kind of stuff that you want done with assertions are enabled and probably wouldn't want enable if assertions were turned off, even if that were to somehow happen without -release.In any case, -debug and debug{} should be explained in the docs somewhere. It's certainly not the sort of thing that I would expect you to magically know.Yes.
Oct 07 2012
On Sunday, October 07, 2012 09:27:31 denizzzka wrote:I've got a situation that debug information should be placed into the class via the constructor. Therefore, when used -debug constructor has another arguments list, and its need debug {} else {} for ctor calling.Which is fine. It's just that you need to realize that debug blocks are enabled with -debug and have nothing to do with whether -release is used or not, so it doesn't correspond with what people typically mean when they talk about debug mode and release mode. - Jonathan M Davis
Oct 07 2012
On 10/6/12, denizzzka <4denizzz gmail.com> wrote:This is bug or feature? http://dlang.org/version.html says what it is correct code, because "assert" in the list of "Predefined Version Identifiers"I think that must be a typo on the website. Use version(debug) instead.
Oct 06 2012
Strange, when you write to the forum then you solve problem immediately by yourself :-) Thx for fast answers!
Oct 06 2012
On 10/6/12, denizzzka <4denizzz gmail.com> wrote:Strange, when you write to the forum then you solve problem immediately by yourself :-)That happens to me all the time too. :)
Oct 06 2012
On Saturday, 6 October 2012 at 18:15:49 UTC, Andrej Mitrovic wrote:On 10/6/12, denizzzka <4denizzz gmail.com> wrote:No, debug also don't works. Debug and Assert works fineThis is bug or feature? http://dlang.org/version.html says what it is correct code, because "assert" in the list of "Predefined Version Identifiers"I think that must be a typo on the website. Use version(debug) instead.
Oct 06 2012
On 10/6/12, denizzzka <4denizzz gmail.com> wrote:No, debug also don't works. Debug and Assert works fineOh right, I was thinking of this: debug { // blabla } I don't even know why there is a version(Debug) when you can use a debug block.
Oct 06 2012
On Saturday, October 06, 2012 20:21:52 Andrej Mitrovic wrote:I don't even know why there is a version(Debug) when you can use a debug block.There isn't. It's just that it compiles because Debug isn't a keyword. The code within a version(Debug) block won't be compiled in unless you define such a version yourself. - Jonathan M Davis
Oct 06 2012