www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - version(noboundscheck) + friends

reply Timothee Cour <thelastmammoth gmail.com> writes:
A)
How to query for compiler flags, eg whether or not "noboundscheck" was set?

B)
Why aren't we using version=noboundscheck (+ friends) instead of
-noboundscheck?

C)
similar to version(assert) which IIRC was introduced later, could we
introduce version(noboundscheck) (+ friends) ?
Jun 03 2013
next sibling parent reply =?UTF-8?B?QWxpIMOHZWhyZWxp?= <acehreli yahoo.com> writes:
On 06/03/2013 03:11 PM, Timothee Cour wrote:

 A)
 How to query for compiler flags, eg whether or not "noboundscheck" 
was set? version D_NoBoundsChecks: http://dlang.org/version.html
 B)
 Why aren't we using version=noboundscheck (+ friends) instead of
 -noboundscheck?
Because the runtime is not written in D. :) However, it should be easy to translate version=noboundscheck to -noboundscheck.
 C)
 similar to version(assert) which IIRC was introduced later, could we
 introduce version(noboundscheck) (+ friends) ?
It is there! :) (I haven't test it though.) Ali
Jun 03 2013
next sibling parent Timothee Cour <thelastmammoth gmail.com> writes:
Thanks, D_NoBoundsChecks indeed works.


On Mon, Jun 3, 2013 at 3:19 PM, Ali =C7ehreli <acehreli yahoo.com> wrote:

 On 06/03/2013 03:11 PM, Timothee Cour wrote:

 A)
 How to query for compiler flags, eg whether or not "noboundscheck" was
set? version D_NoBoundsChecks: http://dlang.org/version.html
 B)
 Why aren't we using version=3Dnoboundscheck (+ friends) instead of
 -noboundscheck?
Because the runtime is not written in D. :) However, it should be easy to translate version=3Dnoboundscheck to -noboundscheck.
That seems like an unimportant technicality, isn't it? Couldn't we define version=3Dnoboundscheck when noboundscheck is used? Why use version(D_NoBoundsChecks) instead of version(noboundscheck) ?
 C)
 similar to version(assert) which IIRC was introduced later, could we
 introduce version(noboundscheck) (+ friends) ?
It is there! :) (I haven't test it though.) Ali
Jun 03 2013
prev sibling next sibling parent Jonathan M Davis <jmdavisProg gmx.com> writes:
On Monday, June 03, 2013 15:19:22 Ali =C3=87ehreli wrote:
  > B)
  > Why aren't we using version=3Dnoboundscheck (+ friends) instead of=
  > -noboundscheck?
=20
 Because the runtime is not written in D. :) However, it should be eas=
y
 to translate version=3Dnoboundscheck to -noboundscheck.
The runtime _is_ written in D. It's the compiler that isn't, and the co= mpiler=20 itself generates different code based on noboundscheck. But the version= =20 D_NoBoundsChecks is new (it might even be new with this release - certa= inly at=20 most it's a release or two old). We've had the noboundscheck flag far, = far=20 longer than that. The same goes for the assert version. It was only add= ed very=20 recently, but we've always had assertions. Also, if you'll notice, version is _never_ used to control anything tha= t the=20 compiler itself does. It affects code that you write, because of what y= ou've=20 done with version blocks, but the compiler itself doesn't change what i= t does=20 due to the version flag save for which version blocks do or don't get c= ompiled=20 in. Compiler flags are used to control the compiler, not version identi= fiers.=20 All of the standard identifiers are for user code to be able to react t= o what=20 version of the compiler you're using, what system you're on, and what=20= compilation flags you used. The only ones that get set by the user are = user- defined versions. - Jonathan M Davis
Jun 03 2013
prev sibling next sibling parent Timothee Cour <thelastmammoth gmail.com> writes:
Again, this seems like an unimportant technicality.
For user code, whether the logic is handled in the compiler or druntime
shouldn't make a difference, so why not have version(D_NoBoundsChecks)
instead of version(noboundscheck). It makes it more discoverable, and more
consistent with the rest (eg: dmd -debug will imply version(debug) is on).

On Mon, Jun 3, 2013 at 4:29 PM, Jonathan M Davis <jmdavisProg gmx.com>wrote=
:

 On Monday, June 03, 2013 15:19:22 Ali =C7ehreli wrote:
  > B)
  > Why aren't we using version=3Dnoboundscheck (+ friends) instead of
  > -noboundscheck?

 Because the runtime is not written in D. :) However, it should be easy
 to translate version=3Dnoboundscheck to -noboundscheck.
The runtime _is_ written in D. It's the compiler that isn't, and the compiler itself generates different code based on noboundscheck. But the version D_NoBoundsChecks is new (it might even be new with this release - certainly at most it's a release or two old). We've had the noboundscheck flag far, fa=
r
 longer than that. The same goes for the assert version. It was only added
 very
 recently, but we've always had assertions.

 Also, if you'll notice, version is _never_ used to control anything that
 the
 compiler itself does. It affects code that you write, because of what
 you've
 done with version blocks, but the compiler itself doesn't change what it
 does
 due to the version flag save for which version blocks do or don't get
 compiled
 in. Compiler flags are used to control the compiler, not version
 identifiers.
 All of the standard identifiers are for user code to be able to react to
 what
 version of the compiler you're using, what system you're on, and what
 compilation flags you used. The only ones that get set by the user are
 user-
 defined versions.

 - Jonathan M Davis
Jun 03 2013
prev sibling next sibling parent Timothee Cour <thelastmammoth gmail.com> writes:
I meant 'why not have version(noboundscheck) instead of
version(D_NoBoundsChecks)'
of course.

On Mon, Jun 3, 2013 at 4:48 PM, Timothee Cour <thelastmammoth gmail.com>wro=
te:

 Again, this seems like an unimportant technicality.
 For user code, whether the logic is handled in the compiler or druntime
 shouldn't make a difference, so why not have version(D_NoBoundsChecks)
 instead of version(noboundscheck). It makes it more discoverable, and mor=
e
 consistent with the rest (eg: dmd -debug will imply version(debug) is on)=
.
 On Mon, Jun 3, 2013 at 4:29 PM, Jonathan M Davis <jmdavisProg gmx.com>wro=
te:
 On Monday, June 03, 2013 15:19:22 Ali =C7ehreli wrote:
  > B)
  > Why aren't we using version=3Dnoboundscheck (+ friends) instead of
  > -noboundscheck?

 Because the runtime is not written in D. :) However, it should be easy
 to translate version=3Dnoboundscheck to -noboundscheck.
The runtime _is_ written in D. It's the compiler that isn't, and the compiler itself generates different code based on noboundscheck. But the version D_NoBoundsChecks is new (it might even be new with this release - certainly at most it's a release or two old). We've had the noboundscheck flag far, f=
ar
 longer than that. The same goes for the assert version. It was only adde=
d
 very
 recently, but we've always had assertions.

 Also, if you'll notice, version is _never_ used to control anything that
 the
 compiler itself does. It affects code that you write, because of what
 you've
 done with version blocks, but the compiler itself doesn't change what it
 does
 due to the version flag save for which version blocks do or don't get
 compiled
 in. Compiler flags are used to control the compiler, not version
 identifiers.
 All of the standard identifiers are for user code to be able to react to
 what
 version of the compiler you're using, what system you're on, and what
 compilation flags you used. The only ones that get set by the user are
 user-
 defined versions.

 - Jonathan M Davis
Jun 03 2013
prev sibling next sibling parent reply "Ivan Kazmenko" <gassa mail.ru> writes:
By the way, what is the naming convention of predefined versions? 
  I am having a hard time trying to figure it out by myself from 
the docs (http://dlang.org/version.html#PredefinedVersions).

To me, it would make sense if all predefined versions started 
with "D_" or something similar to avoid conflicts with user 
versions.  Currently, the exceptions are vendor-related and 
architecture-related (a whole lot of them, actually) as well as 
the following:

unittest
assert
all
none

Now, "all" and "none" are clearly special.  But, really, what's 
the conceptual difference between "unittest", "assert" and 
"D_NoBoundsChecks" which results in using the different naming 
convention?

Ivan Kazmenko.
Jun 03 2013
next sibling parent Jonathan M Davis <jmdavisProg gmx.com> writes:
On Tuesday, June 04, 2013 05:17:08 Ivan Kazmenko wrote:
 By the way, what is the naming convention of predefined versions?
   I am having a hard time trying to figure it out by myself from
 the docs (http://dlang.org/version.html#PredefinedVersions).
 
 To me, it would make sense if all predefined versions started
 with "D_" or something similar to avoid conflicts with user
 versions.  Currently, the exceptions are vendor-related and
 architecture-related (a whole lot of them, actually) as well as
 the following:
 
 unittest
 assert
 all
 none
 
 Now, "all" and "none" are clearly special.  But, really, what's
 the conceptual difference between "unittest", "assert" and
 "D_NoBoundsChecks" which results in using the different naming
 convention?
Sorry. There is no naming convention. It's completely arbitrary. They were added haphazardly over time, and AFAIK, there was never any real effort when adding them to make them consistent, or if there was, the conventions weren't followed consistently throughout, and the end result is that there really is no naming convention. And Walter didn't want to change any of them later, because that would break code (and potentially do so in silent and nasty ways). So, we're stuck with an incredibly inconsistent set of names. - Jonathan M Davis
Jun 03 2013
prev sibling parent Timothee Cour <thelastmammoth gmail.com> writes:
We really should aim to minimize the
wtfpm<http://davidlongstreet.wordpress.com/2009/04/29/new-software-metric-wtfs-per-minute/>
for
future users. I propose:
* support version(nocheckbounds) with same meaning as version(
D_NoBoundsChecks)
* list D_NoBoundsChecks as soft-deprecated. By soft-deprecated I mean list
it in http://dlang.org/deprecate.html but keep it for now, perhaps
indefinitely.


On Mon, Jun 3, 2013 at 8:25 PM, Jonathan M Davis <jmdavisProg gmx.com>wrote:

 On Tuesday, June 04, 2013 05:17:08 Ivan Kazmenko wrote:
 By the way, what is the naming convention of predefined versions?
   I am having a hard time trying to figure it out by myself from
 the docs (http://dlang.org/version.html#PredefinedVersions).

 To me, it would make sense if all predefined versions started
 with "D_" or something similar to avoid conflicts with user
 versions.  Currently, the exceptions are vendor-related and
 architecture-related (a whole lot of them, actually) as well as
 the following:

 unittest
 assert
 all
 none

 Now, "all" and "none" are clearly special.  But, really, what's
 the conceptual difference between "unittest", "assert" and
 "D_NoBoundsChecks" which results in using the different naming
 convention?
Sorry. There is no naming convention. It's completely arbitrary. They were added haphazardly over time, and AFAIK, there was never any real effort when adding them to make them consistent, or if there was, the conventions weren't followed consistently throughout, and the end result is that there really is no naming convention. And Walter didn't want to change any of them later, because that would break code (and potentially do so in silent and nasty ways). So, we're stuck with an incredibly inconsistent set of names. - Jonathan M Davis
Jun 03 2013
prev sibling parent reply "eles" <eles eles.com> writes:
On Monday, 3 June 2013 at 22:19:23 UTC, Ali Çehreli wrote:
 On 06/03/2013 03:11 PM, Timothee Cour wrote:
 Why aren't we using version=noboundscheck (+ friends) instead
of
 -noboundscheck?
Hijack: what about version(integeroverflow) ?
Jun 04 2013
next sibling parent reply Jonathan M Davis <jmdavisProg gmx.com> writes:
On Tuesday, June 04, 2013 09:14:28 eles wrote:
 On Monday, 3 June 2013 at 22:19:23 UTC, Ali =C3=87ehreli wrote:
 On 06/03/2013 03:11 PM, Timothee Cour wrote:
 Why aren't we using version=3Dnoboundscheck (+ friends) instead
=20 of =20
 -noboundscheck?
=20 Hijack: what about version(integeroverflow)
Nothing in the language checks for integer overflow, and given the over= head=20 that it would introduce, there's pretty much no way that it's ever goin= g to be=20 added. Walter has been against it every time that it's come up. - Jonathan M Davis
Jun 04 2013
parent reply "eles" <eles eles.com> writes:
On Tuesday, 4 June 2013 at 07:19:52 UTC, Jonathan M Davis wrote:
 On Tuesday, June 04, 2013 09:14:28 eles wrote:
 On Monday, 3 June 2013 at 22:19:23 UTC, Ali Çehreli wrote:
 On 06/03/2013 03:11 PM, Timothee Cour wrote:
Nothing in the language checks for integer overflow, and given the overhead that it would introduce, there's pretty much no way that it's ever going to be added.
Just the same can be said about bounds checking. And those came into the language, however.
 Walter has been against it every time that it's come up.
Yes, even in the -debug mode. What I fail to see is why. The overhead will be there only if asked for, only in debug mode.
Jun 04 2013
parent Jonathan M Davis <jmdavisProg gmx.com> writes:
On Tuesday, June 04, 2013 09:30:07 eles wrote:
 On Tuesday, 4 June 2013 at 07:19:52 UTC, Jonathan M Davis wrote:
 Walter has been against it every time that it's come up.
Yes, even in the -debug mode. What I fail to see is why. The overhead will be there only if asked for, only in debug mode.
This is why I hate the -debug flag. Its name causes too much confusion. _All_ that -debug does or will ever do is enable debug {} blocks. It has _nothing_ to do with release builds vs debug builds other than the fact that odds are you're going to want to use -debug with debug builds and not release builds. If integer overflow were enabled for "debug" builds it would be enabled when -release wasn't use - the same as assertions or when a specific flag was used to enable it. - Jonathan m Davis
Jun 04 2013
prev sibling parent Timothee Cour <thelastmammoth gmail.com> writes:
 given the overhead that it would introduce
Do you mean compiler-implementation overhead or resulting runtime overhead? If you mean runtime overhead then I disagree, as this would be an opt-in option enabled with, say, a version identifier such as version=3Dcheck_arithmetic_overflow (same as version=3Dassert + friends); i= t would not be implied by version=3Ddebug, so it wouldn't slow down normal debug builds (as the slow down might be significant), but would save hours of debugging to track down overflow bugs when the user requests it explicitly. I've described this precisely in my post: http://forum.dlang.org/thread/kn3f9v$25pd$1 digitalmars.com?page=3D2#post-m= ailman.161.1369525278.13711.digitalmars-d:40puremagic.com but it received no answer. On Tue, Jun 4, 2013 at 12:19 AM, Jonathan M Davis <jmdavisProg gmx.com>wrot= e:
 On Tuesday, June 04, 2013 09:14:28 eles wrote:
 On Monday, 3 June 2013 at 22:19:23 UTC, Ali =C7ehreli wrote:
 On 06/03/2013 03:11 PM, Timothee Cour wrote:
 Why aren't we using version=3Dnoboundscheck (+ friends) instead
of
 -noboundscheck?
Hijack: what about version(integeroverflow)
Nothing in the language checks for integer overflow, and given the overhe=
ad
 that it would introduce, there's pretty much no way that it's ever going
 to be
 added. Walter has been against it every time that it's come up.

 - Jonathan M Davis
Jun 04 2013
prev sibling next sibling parent Jonathan M Davis <jmdavisProg gmx.com> writes:
On Monday, June 03, 2013 16:49:29 Timothee Cour wrote:
 I meant 'why not have version(noboundscheck) instead of
 version(D_NoBoundsChecks)'
 of course.
So, you're complaining about the name of the version identifier? I thought that you were complaining that we were using a flag instead a version identifier to turn on noboundscheck. I don't know why that name was chosen or even who chose it. If you look at the list of official identifiers, you can see that it's pretty arbitrary as to what the exact naming scheme is. Not even the casing is consistent. So, I expect that D_NoBoundsCheck was chosen simply because whoever picked it thought that it best followed the generally naming scheme, or they just preferred that name. As it stands, there's really no hope of being able to figure out what any of the official version identifiers are without looking them up and memorizing them - including the spelling and whatever other naming quirks that particular identifier may have. And unfortunately, there's no way that that's going to be fixed at this point due to code breakage that it would cause. You might be able to get D_NoBoundsChecks changed given how new it is, but I don't know. - Jonathan M Davis
Jun 03 2013
prev sibling next sibling parent Timothee Cour <thelastmammoth gmail.com> writes:
A)
whether the logic is done in compiler or druntime shouldn't matter to user,
so it'd be nice to use as uniform syntax as possible, ie:
dmd -version=noboundscheck should be supported (in addition to existing
-noboundscheck)
Implementation can then use that version flag to set compiler
flag -noboundscheck.

B)
noboundscheck can be used in library code as well for similar bounds
checking semantics: for example, checking index bounds inside a user
defined opIndex method. Hence distinguishing between compiler flag vs
version flag doesn't make that much sense.

C)
It was introduced here:
https://github.com/D-Programming-Language/dlang.org/commit/a4e2aa3ef7e4a6eec1c726ac9492221507cacfcf#version.dd
by  alexrp.

Since it wasn't in any change log, it's recent and makes sense, can we
start a deprecation path to have D_NoBoundsChecks => noboundscheck ?


On Mon, Jun 3, 2013 at 5:46 PM, Jonathan M Davis <jmdavisProg gmx.com>wrote:

 On Monday, June 03, 2013 16:49:29 Timothee Cour wrote:
 I meant 'why not have version(noboundscheck) instead of
 version(D_NoBoundsChecks)'
 of course.
So, you're complaining about the name of the version identifier? I thought that you were complaining that we were using a flag instead a version identifier to turn on noboundscheck. I don't know why that name was chosen or even who chose it. If you look at the list of official identifiers, you can see that it's pretty arbitrary as to what the exact naming scheme is. Not even the casing is consistent. So, I expect that D_NoBoundsCheck was chosen simply because whoever picked it thought that it best followed the generally naming scheme, or they just preferred that name. As it stands, there's really no hope of being able to figure out what any of the official version identifiers are without looking them up and memorizing them - including the spelling and whatever other naming quirks that particular identifier may have. And unfortunately, there's no way that that's going to be fixed at this point due to code breakage that it would cause. You might be able to get D_NoBoundsChecks changed given how new it is, but I don't know. - Jonathan M Davis
Jun 03 2013
prev sibling next sibling parent Jonathan M Davis <jmdavisProg gmx.com> writes:
On Monday, June 03, 2013 18:57:07 Timothee Cour wrote:
 A)
 whether the logic is done in compiler or druntime shouldn't matter to user,
 so it'd be nice to use as uniform syntax as possible, ie:
 dmd -version=noboundscheck should be supported (in addition to existing
 -noboundscheck)
 Implementation can then use that version flag to set compiler
 flag -noboundscheck.
I disagree. -version is for user-defined version identifiers, not official ones.
 B)
 noboundscheck can be used in library code as well for similar bounds
 checking semantics: for example, checking index bounds inside a user
 defined opIndex method. Hence distinguishing between compiler flag vs
 version flag doesn't make that much sense.
There isn't a need to disambiguate. If -noboundscheck is used, then D_NoBoundsCheck is defined. No one should ever be passing -version=D_NoBoundsCheck to dmd. It's exactly the same with versions such as linux or X86. It's the compiler that sets those.
 C)
 It was introduced here:
 https://github.com/D-Programming-Language/dlang.org/commit/a4e2aa3ef7e4a6eec
 1c726ac9492221507cacfcf#version.dd by  alexrp.
 
 Since it wasn't in any change log, it's recent and makes sense, can we
 start a deprecation path to have D_NoBoundsChecks => noboundscheck ?
That would be up to the compiler devs. I deal with Phobos and to some extent druntime but don't do any work on the compiler. - Jonathan M Davis
Jun 03 2013
prev sibling next sibling parent Jonathan M Davis <jmdavisProg gmx.com> writes:
On Monday, June 03, 2013 23:17:03 Timothee Cour wrote:
 We really should aim to minimize the
 wtfpm<http://davidlongstreet.wordpress.com/2009/04/29/new-software-metric-wt
 fs-per-minute/> for
 future users. I propose:
 * support version(nocheckbounds) with same meaning as version(
 D_NoBoundsChecks)
 * list D_NoBoundsChecks as soft-deprecated. By soft-deprecated I mean list
 it in http://dlang.org/deprecate.html but keep it for now, perhaps
 indefinitely.
Feel free to make an enhancement request: http//d.puremagic.com/issues And if you can track down which commit added D_NoBoundsChecks, it might even be easy to figure out how to implement it yourself and submit a pull request. Given the fact that the entire list version identifiers is one big WTF, and we're not going to fix the general problem due to the code brekage that it would cause, I don't see much point in worrying about it, but feel free to try and get it changed. - Jonathan M Davis
Jun 03 2013
prev sibling next sibling parent Jonathan M Davis <jmdavisProg gmx.com> writes:
On Tuesday, June 04, 2013 00:38:17 Timothee Cour wrote:
 given the overhead that it would introduce
Do you mean compiler-implementation overhead or resulting runtime overhead?
I'm talking about runtime overhead, and Walter is flat-out against it. Anyone who wants it even in just non-release mode has to figure out how to convince him, and no one has been able to do that. - Jonathan M Davis
Jun 04 2013
prev sibling next sibling parent Timothee Cour <thelastmammoth gmail.com> writes:
What are his arguments against an opt-in flag such as
version=check_arithmetic_overflow ?

* slowing down code is a very weak argument precisely because this would be
an opt-in flag (and wouldn't be implied by version=debug in my proposal).

* reliance on intentional overflow arithmetics could be easily protected
with version blocks or similar. This should be the exception, not the norm,
and I bet we would start finding existing bugs with such a flag enabled.

* the resulting (relatively small) increased complexity of the compiler
would be dwarfed by the time
savings this would enable for everyone in bug chasing mode




On Tue, Jun 4, 2013 at 12:40 AM, Jonathan M Davis <jmdavisProg gmx.com>wrote:

 On Tuesday, June 04, 2013 00:38:17 Timothee Cour wrote:
 given the overhead that it would introduce
Do you mean compiler-implementation overhead or resulting runtime
overhead? I'm talking about runtime overhead, and Walter is flat-out against it. Anyone who wants it even in just non-release mode has to figure out how to convince him, and no one has been able to do that. - Jonathan M Davis
Jun 04 2013
prev sibling parent Jonathan M Davis <jmdavisProg gmx.com> writes:
On Tuesday, June 04, 2013 00:57:09 Timothee Cour wrote:
 What are his arguments against an opt-in flag such as
 version=check_arithmetic_overflow ?
I'm sure that you can find his arguments in a number of threads that have discussed integer overflow. And if you want to get the situation changed, you're going to have to talk him into it. Discussing it with me isn't going to help you any. He's against it primarily for performance reasons and doesn't want to add it in non-release mode any more than he wants to add checks for null pointers/references in non-release mode. He also dislikes having lots of compiler flags, so it's generally very difficult to talk him into anything that requires a new compiler flag. And as I pointed out before, there are _zero_ cases where -version is used to enable compiler-defined versions. If it were added as a new flag it would be something like -checkoverflow and not as a version identifier. -version is only for user-defined versions identifiers. - Jonathan M Davis
Jun 04 2013