digitalmars.D.announce - DMD 1.027 and 2.011 releases
- Walter Bright (7/7) Feb 19 2008 A whole lotta library improvements.
- Jarrett Billingsley (5/12) Feb 19 2008 .tupleof can now access private fields of a struct/class
- Walter Bright (3/7) Feb 19 2008 I guess that depends on if it's an enhancement or a bug fix. Obviously,
- Jarrett Billingsley (3/10) Feb 19 2008 Obviously I do ;) Especially since it's not mentioned anywhere in the s...
- Vladimir Panteleev (7/14) Feb 19 2008 That looks great!
- BCS (2/11) Feb 19 2008 Is there now some way to force dmd to output the link command?
- Walter Bright (2/3) Feb 19 2008 -v
- BCS (2/8) Feb 19 2008 :)
- Frank Benoit (3/8) Feb 20 2008 For me it still prints the gcc line.
- Extrawurst (16/23) Feb 19 2008 Wow what a huge changelist for the std lib, awesome !
- Walter Bright (3/23) Feb 19 2008 Because I reimplemented the flow analysis, and it looks like there's a
- Extrawurst (2/25) Feb 20 2008 i made an entry in bugzilla
- Walter Bright (2/3) Feb 20 2008 Thank you.
- Saaa (1/1) Feb 19 2008 Is it possible to check how many known bugs are still unsolved for D1 ?
- Walter Bright (2/3) Feb 19 2008 I think you can get that from bugzilla.
- Bill Baxter (7/17) Feb 19 2008 For all who care, Tango appears to compile with D1.027.
- torhu (8/9) Feb 19 2008 I had to copy and paste the 2.0 changelog into my editor to be able to
- Bill Baxter (7/18) Feb 19 2008 The font is pretty darned small over here too. Also WinXP/FF2. I
- Walter Bright (4/9) Feb 19 2008 That's good feedback. You can try tweaking the style.css, and let me
- Jacob Carlborg (3/15) Feb 20 2008 Why not use the same style sheet for D 1 and 2 or do you want them to
- Walter Bright (2/4) Feb 20 2008 I think it's a good idea that they look a bit different.
- Bill Baxter (4/9) Feb 20 2008 I do like that there's a difference. But I think the color scheme may
- Jacob Carlborg (3/14) Feb 20 2008 Why not just add "font-family: Helvetica, Verdana, Arial, sans-serif;"
- Unknown W. Brackets (3/15) Feb 22 2008 I sent you an email, did you receive it? Or did I use the wrong address...
- Jacob Carlborg (2/23) Feb 20 2008 It's the same in osx/ff3beta and osx/safari
- Jascha Wetzel (2/13) Feb 20 2008 it's readable but still *pretty* small on ff2/linux and opera/vista
- Don Clugston (4/14) Feb 19 2008 Thanks!
- Max Samukha (5/15) Feb 20 2008 Thanks!
- Walter Bright (2/5) Feb 20 2008 Try it now.
- Max Samukha (2/8) Feb 20 2008 Fixed.
- Extrawurst (3/10) Feb 20 2008 btw. whats the nothrow keyword gonna be for ?
- Jacob Carlborg (2/18) Feb 20 2008 Indicating that a function/method won't throw an exception?
- Extrawurst (3/21) Feb 20 2008 yeah but what happend to the express-such-things-via-documention policy
- Jacob Carlborg (2/25) Feb 20 2008 The compiler can probably do some optimization if it knows that
- Walter Bright (2/3) Feb 20 2008 Exactly. This will become more important later.
- Graham St Jack (4/11) Feb 20 2008 It is also very helpful when writing code to know that a function you ar...
- Walter Bright (14/18) Feb 20 2008 Experience with this indicates that it is impractical to specify what
- Georg Wrede (12/37) Feb 21 2008 So both of you are right!
- Manfred Nowak (4/5) Feb 21 2008 This holds also for the reduction to the three states Always, Never,
- Walter Bright (2/8) Feb 21 2008 If they are part of the type signature, then it can be enforced.
- Manfred Nowak (5/6) Feb 21 2008 For this one would have to ensure that the prerequisites of Rice's
- Walter Bright (3/11) Feb 22 2008 Don't have to compute it, just check it since it's part of the type
- Manfred Nowak (4/6) Feb 22 2008 Enforcing, checking but not computing? I don't get that. So I'll have
- =?ISO-8859-15?Q?S=F6nke_Ludwig?= (8/18) Feb 22 2008 If you specify that some function does not throw an exception, you can e...
- Robert Fraser (5/27) Feb 22 2008 According to the conference slides, it'll allow any function that just
- Walter Bright (3/11) Feb 22 2008 It would work just like "nothrow" does for C++.
- Manfred Nowak (4/5) Feb 24 2008 BTW, wasn't there one of your arguments to have no negation in
- Walter Bright (2/9) Feb 24 2008
- Derek Parnell (6/15) Feb 24 2008 ROTFLMAO
- Graham St Jack (4/5) Feb 24 2008 Just checking - I hope this means that if a nothrow function actually DI...
- Walter Bright (2/8) Feb 24 2008 No, but it will try to detect errors at compile time.
- Ary Borenszweig (13/23) Feb 25 2008 Does this mean this will not compile:
- Walter Bright (2/17) Feb 25 2008 I don't know yet. But the idea is to do static checking of what can thro...
- Graham St Jack (8/27) Feb 25 2008 It will be a good trick if you can pull it off. I don't see how it can b...
- Walter Bright (2/10) Feb 25 2008
- Sean Kelly (5/13) Feb 26 2008 I think it depends on the compiler. The MS compiler, for example, ignor...
- Graham St Jack (13/26) Feb 26 2008 g++ certainly does runtime checking. I'm sure it does no static checking...
- Sean Kelly (6/29) Feb 26 2008 The nice thing about offering nothrow only is that it implicitly marks a...
- Graham St Jack (2/35) Feb 26 2008 Agreed.
- Georg Wrede (16/31) Mar 03 2008 IMHO, it would behoove the compiler to keep track of possible/potential
- Christopher Wright (7/28) Mar 03 2008 There's a few problems with what you're asking for:
- Georg Wrede (50/62) Mar 07 2008 Caveat lector!
- Robert Fraser (5/8) Feb 26 2008 I think the idea would be that nothrow is part of the function signature...
- Graham St Jack (3/12) Feb 27 2008 That would work, but my feeling is that it would be so restrictive that
- Georg Wrede (10/21) Mar 03 2008 Yes. Therefore, the compiler has to know which functions are "nothrow",
- eao197 (31/46) Feb 25 2008 Just my $0.02 about nothrow and DesignByContract: I think that nothrow a...
- Robert Fraser (9/59) Feb 26 2008 So the code generated depends on compiler switches... Isn't this always
- eao197 (24/76) Feb 27 2008 =
- Ary Borenszweig (6/16) Feb 27 2008 But contracts are predictable. Say B extends A, and A has a foo method.
- eao197 (13/26) Feb 27 2008 B.foo may looks like:
- Christopher Wright (4/15) Feb 27 2008 I'm happy with that. Contracts aren't compiled in release mode, and they...
- eao197 (10/24) Feb 27 2008 People are different. You want to compile your programs in release mode ...
- Russell Lewis (9/36) Feb 27 2008 I wonder if asserts() should be the exception to nothrow. Like eao197,
- eao197 (140/175) Feb 28 2008 , =
- Russell Lewis (21/42) Feb 28 2008 I agree that a web server needs to post an appropriate response. But if...
- eao197 (45/57) Feb 29 2008 to =
- Russell Lewis (26/76) Feb 29 2008 It seems that we have a significant programming style difference. Let
- eao197 (65/130) Feb 29 2008 =
- Charles D Hixson (22/41) Feb 29 2008 ...
- Russell Lewis (7/25) Feb 25 2008 The example would be (reasonably) compilable, without whole-program
- Jason House (16/33) Feb 25 2008 I sincerely hope that design by contract will allow for us to iron out
- Christopher Wright (5/15) Feb 25 2008 And nothrow will be a valid part of a delegate signature, correct? So I
- Leandro Lucarella (14/37) Feb 25 2008 And what's the difference with nothrow? foo.bar's nothrow-ness "is not
- Georg Wrede (4/39) Mar 03 2008 Of course, there should be a Nothrow-offense exception. Right?!!
- Robert Fraser (5/7) Feb 21 2008 It looks like the bane of all my Java existence, exception
- Ary Borenszweig (3/11) Feb 21 2008 In fact, it's just serves as a hint to the compiler, right? Like
- lutger (5/17) Feb 21 2008 In the slides from the conference it is mentioned that nothrow is static...
- Walter Bright (2/10) Feb 21 2008 The downsides of general exception specifications are not shared by noth...
- Bruno Medeiros (6/8) Feb 28 2008 Cool, and about time! :) I've just tried it out and it's so much more
A whole lotta library improvements. http://www.digitalmars.com/d/1.0/changelog.html http://ftp.digitalmars.com/dmd.1.027.zip http://www.digitalmars.com/d/2.0/changelog.html http://ftp.digitalmars.com/dmd.2.011.zip I had planned on doing struct destructors for this update, but they are not done yet.
Feb 19 2008
"Walter Bright" <newshound1 digitalmars.com> wrote in message news:fpf9bk$2upn$1 digitalmars.com...A whole lotta library improvements. http://www.digitalmars.com/d/1.0/changelog.html http://ftp.digitalmars.com/dmd.1.027.zip http://www.digitalmars.com/d/2.0/changelog.html http://ftp.digitalmars.com/dmd.2.011.zip I had planned on doing struct destructors for this update, but they are not done yet..tupleof can now access private fields of a struct/class Any reason why this was fixed in D2 but not in D1? My binding library is still broken because of it..
Feb 19 2008
Jarrett Billingsley wrote:.tupleof can now access private fields of a struct/class Any reason why this was fixed in D2 but not in D1? My binding library is still broken because of it..I guess that depends on if it's an enhancement or a bug fix. Obviously, you consider it the latter :-)
Feb 19 2008
"Walter Bright" <newshound1 digitalmars.com> wrote in message news:fpfco5$7j5$1 digitalmars.com...Jarrett Billingsley wrote:Obviously I do ;) Especially since it's not mentioned anywhere in the spec..tupleof can now access private fields of a struct/class Any reason why this was fixed in D2 but not in D1? My binding library is still broken because of it..I guess that depends on if it's an enhancement or a bug fix. Obviously, you consider it the latter :-)
Feb 19 2008
On Tue, 19 Feb 2008 21:06:31 +0200, Walter Bright <newshound1 digitalmars.com> wrote:A whole lotta library improvements. http://www.digitalmars.com/d/1.0/changelog.html http://ftp.digitalmars.com/dmd.1.027.zip http://www.digitalmars.com/d/2.0/changelog.html http://ftp.digitalmars.com/dmd.2.011.zip I had planned on doing struct destructors for this update, but they are not done yet.That looks great! However, D1's Phobos did not get any of the fixes? Also, it seems that bug 1815 doesn't belong in D1's changelog. -- Best regards, Vladimir mailto:thecybershadow gmail.com
Feb 19 2008
Reply to Walter,A whole lotta library improvements. http://www.digitalmars.com/d/1.0/changelog.html http://ftp.digitalmars.com/dmd.1.027.zip http://www.digitalmars.com/d/2.0/changelog.html http://ftp.digitalmars.com/dmd.2.011.zip I had planned on doing struct destructors for this update, but they are not done yet.Is there now some way to force dmd to output the link command?
Feb 19 2008
BCS wrote:Is there now some way to force dmd to output the link command?-v
Feb 19 2008
Reply to Walter,BCS wrote::)Is there now some way to force dmd to output the link command?-v
Feb 19 2008
Walter Bright schrieb:BCS wrote:For me it still prints the gcc line. I use dmd 1.027 on linux.Is there now some way to force dmd to output the link command?-v
Feb 20 2008
Wow what a huge changelist for the std lib, awesome ! But i wonder about one thing: [CODE] class Foo { int foo() { synchronized(this){ return 8; } } } [/CODE] why does 2.011 in contrast to the previous 2.010 warn me with "warning - main.d(3): function main.Foo.foo no return at end of function" ? why is this a probem suddenly ? i have plenty of this warnings spit out in my project now ;( Walter Bright schrieb:A whole lotta library improvements. http://www.digitalmars.com/d/1.0/changelog.html http://ftp.digitalmars.com/dmd.1.027.zip http://www.digitalmars.com/d/2.0/changelog.html http://ftp.digitalmars.com/dmd.2.011.zip I had planned on doing struct destructors for this update, but they are not done yet.
Feb 19 2008
Extrawurst wrote:Wow what a huge changelist for the std lib, awesome ! But i wonder about one thing: [CODE] class Foo { int foo() { synchronized(this){ return 8; } } } [/CODE] why does 2.011 in contrast to the previous 2.010 warn me with "warning - main.d(3): function main.Foo.foo no return at end of function" ? why is this a probem suddenly ? i have plenty of this warnings spit out in my project now ;(Because I reimplemented the flow analysis, and it looks like there's a bug in it :-(
Feb 19 2008
Walter Bright schrieb:Extrawurst wrote:i made an entry in bugzillaWow what a huge changelist for the std lib, awesome ! But i wonder about one thing: [CODE] class Foo { int foo() { synchronized(this){ return 8; } } } [/CODE] why does 2.011 in contrast to the previous 2.010 warn me with "warning - main.d(3): function main.Foo.foo no return at end of function" ? why is this a probem suddenly ? i have plenty of this warnings spit out in my project now ;(Because I reimplemented the flow analysis, and it looks like there's a bug in it :-(
Feb 20 2008
Extrawurst wrote:i made an entry in bugzillaThank you.
Feb 20 2008
Is it possible to check how many known bugs are still unsolved for D1 ?
Feb 19 2008
Saaa wrote:Is it possible to check how many known bugs are still unsolved for D1 ?I think you can get that from bugzilla.
Feb 19 2008
Walter Bright wrote:A whole lotta library improvements. http://www.digitalmars.com/d/1.0/changelog.html http://ftp.digitalmars.com/dmd.1.027.zip http://www.digitalmars.com/d/2.0/changelog.html http://ftp.digitalmars.com/dmd.2.011.zip I had planned on doing struct destructors for this update, but they are not done yet.For all who care, Tango appears to compile with D1.027. (It didn't compile with D1.026 -- some errors about "scope". I tested with the SVN version of Tango with DMD. I did not try the 0.99.4 "Frank" release, or GCD so I can't vouch for those.) --bb
Feb 19 2008
Walter Bright wrote:A whole lotta library improvements.I had to copy and paste the 2.0 changelog into my editor to be able to even read it. Would it be possible to get a readable font face and size? There is no shame in just using black text on a white background either. Please? I use FF 2 on winxp, so I don't think I have a weird setup. 19 inch CRT, 1152x864. That's pretty mainstream, and the 1.0 docs look just fine on my screen.
Feb 19 2008
torhu wrote:Walter Bright wrote:The font is pretty darned small over here too. Also WinXP/FF2. I wouldn't say unreadable, but the 1.0 changelog is definitely easier on the eyes. I thought a web developer was helping you to make the D site more modern. Is this the result of that? Or is that yet to come? --bbA whole lotta library improvements.I had to copy and paste the 2.0 changelog into my editor to be able to even read it. Would it be possible to get a readable font face and size? There is no shame in just using black text on a white background either. Please? I use FF 2 on winxp, so I don't think I have a weird setup. 19 inch CRT, 1152x864. That's pretty mainstream, and the 1.0 docs look just fine on my screen.
Feb 19 2008
Bill Baxter wrote:The font is pretty darned small over here too. Also WinXP/FF2. I wouldn't say unreadable, but the 1.0 changelog is definitely easier on the eyes.That's good feedback. You can try tweaking the style.css, and let me know what makes it look better.I thought a web developer was helping you to make the D site more modern. Is this the result of that? Or is that yet to come?That kinda fizzled out.
Feb 19 2008
Walter Bright wrote:Bill Baxter wrote:Why not use the same style sheet for D 1 and 2 or do you want them to look different?The font is pretty darned small over here too. Also WinXP/FF2. I wouldn't say unreadable, but the 1.0 changelog is definitely easier on the eyes.That's good feedback. You can try tweaking the style.css, and let me know what makes it look better.I thought a web developer was helping you to make the D site more modern. Is this the result of that? Or is that yet to come?That kinda fizzled out.
Feb 20 2008
Jacob Carlborg wrote:Why not use the same style sheet for D 1 and 2 or do you want them to look different?I think it's a good idea that they look a bit different.
Feb 20 2008
Walter Bright wrote:Jacob Carlborg wrote:I do like that there's a difference. But I think the color scheme may be enough to achieve that. --bbWhy not use the same style sheet for D 1 and 2 or do you want them to look different?I think it's a good idea that they look a bit different.
Feb 20 2008
Bill Baxter wrote:Walter Bright wrote:Why not just add "font-family: Helvetica, Verdana, Arial, sans-serif;" in D 2's style sheet in "body" like D 1 hasJacob Carlborg wrote:I do like that there's a difference. But I think the color scheme may be enough to achieve that. --bbWhy not use the same style sheet for D 1 and 2 or do you want them to look different?I think it's a good idea that they look a bit different.
Feb 20 2008
I sent you an email, did you receive it? Or did I use the wrong address? -[Unknown] Walter Bright wrote:Bill Baxter wrote:The font is pretty darned small over here too. Also WinXP/FF2. I wouldn't say unreadable, but the 1.0 changelog is definitely easier on the eyes.That's good feedback. You can try tweaking the style.css, and let me know what makes it look better.I thought a web developer was helping you to make the D site more modern. Is this the result of that? Or is that yet to come?That kinda fizzled out.
Feb 22 2008
Bill Baxter wrote:torhu wrote:It's the same in osx/ff3beta and osx/safariWalter Bright wrote:The font is pretty darned small over here too. Also WinXP/FF2. I wouldn't say unreadable, but the 1.0 changelog is definitely easier on the eyes. I thought a web developer was helping you to make the D site more modern. Is this the result of that? Or is that yet to come? --bbA whole lotta library improvements.I had to copy and paste the 2.0 changelog into my editor to be able to even read it. Would it be possible to get a readable font face and size? There is no shame in just using black text on a white background either. Please? I use FF 2 on winxp, so I don't think I have a weird setup. 19 inch CRT, 1152x864. That's pretty mainstream, and the 1.0 docs look just fine on my screen.
Feb 20 2008
torhu wrote:Walter Bright wrote:it's readable but still *pretty* small on ff2/linux and opera/vistaA whole lotta library improvements.I had to copy and paste the 2.0 changelog into my editor to be able to even read it. Would it be possible to get a readable font face and size? There is no shame in just using black text on a white background either. Please? I use FF 2 on winxp, so I don't think I have a weird setup. 19 inch CRT, 1152x864. That's pretty mainstream, and the 1.0 docs look just fine on my screen.
Feb 20 2008
Walter Bright wrote:A whole lotta library improvements. http://www.digitalmars.com/d/1.0/changelog.html http://ftp.digitalmars.com/dmd.1.027.zip http://www.digitalmars.com/d/2.0/changelog.html http://ftp.digitalmars.com/dmd.2.011.zip I had planned on doing struct destructors for this update, but they are not done yet.Thanks! What happened to my fixes to std.math? They are still in phobos candidate, but not in the trunk.
Feb 19 2008
Walter Bright wrote:A whole lotta library improvements. http://www.digitalmars.com/d/1.0/changelog.html http://ftp.digitalmars.com/dmd.1.027.zip http://www.digitalmars.com/d/2.0/changelog.html http://ftp.digitalmars.com/dmd.2.011.zip I had planned on doing struct destructors for this update, but they are not done yet.Thanks! If anybody cares about Konqueror, phobos 2 docs layout is broken in Konqueror 3 and 4. I suspect this is because of the possibly redundant </div> tag right above <div id="content">.
Feb 20 2008
Max Samukha wrote:If anybody cares about Konqueror, phobos 2 docs layout is broken in Konqueror 3 and 4. I suspect this is because of the possibly redundant </div> tag right above <div id="content">.Try it now.
Feb 20 2008
Walter Bright wrote:Max Samukha wrote:Fixed.If anybody cares about Konqueror, phobos 2 docs layout is broken in Konqueror 3 and 4. I suspect this is because of the possibly redundant </div> tag right above <div id="content">.Try it now.
Feb 20 2008
Walter Bright schrieb:A whole lotta library improvements. http://www.digitalmars.com/d/1.0/changelog.html http://ftp.digitalmars.com/dmd.1.027.zip http://www.digitalmars.com/d/2.0/changelog.html http://ftp.digitalmars.com/dmd.2.011.zip I had planned on doing struct destructors for this update, but they are not done yet.btw. whats the nothrow keyword gonna be for ? ~Extrawurst
Feb 20 2008
Extrawurst wrote:Walter Bright schrieb:Indicating that a function/method won't throw an exception?A whole lotta library improvements. http://www.digitalmars.com/d/1.0/changelog.html http://ftp.digitalmars.com/dmd.1.027.zip http://www.digitalmars.com/d/2.0/changelog.html http://ftp.digitalmars.com/dmd.2.011.zip I had planned on doing struct destructors for this update, but they are not done yet.btw. whats the nothrow keyword gonna be for ? ~Extrawurst
Feb 20 2008
Jacob Carlborg schrieb:Extrawurst wrote:yeah but what happend to the express-such-things-via-documention policy to keep syntax simple ?Walter Bright schrieb:Indicating that a function/method won't throw an exception?A whole lotta library improvements. http://www.digitalmars.com/d/1.0/changelog.html http://ftp.digitalmars.com/dmd.1.027.zip http://www.digitalmars.com/d/2.0/changelog.html http://ftp.digitalmars.com/dmd.2.011.zip I had planned on doing struct destructors for this update, but they are not done yet.btw. whats the nothrow keyword gonna be for ? ~Extrawurst
Feb 20 2008
Extrawurst wrote:Jacob Carlborg schrieb:The compiler can probably do some optimization if it knows thatExtrawurst wrote:yeah but what happend to the express-such-things-via-documention policy to keep syntax simple ?Walter Bright schrieb:Indicating that a function/method won't throw an exception?A whole lotta library improvements. http://www.digitalmars.com/d/1.0/changelog.html http://ftp.digitalmars.com/dmd.1.027.zip http://www.digitalmars.com/d/2.0/changelog.html http://ftp.digitalmars.com/dmd.2.011.zip I had planned on doing struct destructors for this update, but they are not done yet.btw. whats the nothrow keyword gonna be for ? ~Extrawurst
Feb 20 2008
Jacob Carlborg wrote:The compiler can probably do some optimization if it knows thatExactly. This will become more important later.
Feb 20 2008
It is also very helpful when writing code to know that a function you are calling won't throw an exception - it means you have three kinds of functions: those that don't throw, those with comments telling you what they throw, and those that you need to fix the comments for.The compiler can probably do some optimization if it knows thatIndicating that a function/method won't throw an exception?yeah but what happend to the express-such-things-via-documention policy to keep syntax simple ?
Feb 20 2008
Graham St Jack wrote:It is also very helpful when writing code to know that a function you are calling won't throw an exception - it means you have three kinds of functions: those that don't throw, those with comments telling you what they throw, and those that you need to fix the comments for.Experience with this indicates that it is impractical to specify what exceptions a function may throw. The only practical states to specify are: 1) does not throw 2) always throws 3) might throw What is thrown is not reliably computable. For example: import foo; void test() { foo.bar(); } What exceptions does test() throw? That would require knowledge of the import foo, which is not necessarily knowable and can change over time.
Feb 20 2008
Walter Bright wrote:Graham St Jack wrote:So both of you are right! (Heh, couldn't resist ;-) ) What my comment above incidentally uncovers is that this is a profound aspect that especially Programmer Group Managers should be aware of. The ability to see things /simultaneously/ from the perspective of the library programmer, the app programmer, and Real Reality, is fundamental to the success of the Group. If all three of these persons can see it from all three points of view, the better. And much better. (It's a pity that all we have left in Finland currently on the job market are ex-truck-drivers. Everybody else already are in managerial positions at Nokia, F-Secure, and a few other firms.)It is also very helpful when writing code to know that a function you are calling won't throw an exception - it means you have three kinds of functions: those that don't throw, those with comments telling you what they throw, and those that you need to fix the comments for.Experience with this indicates that it is impractical to specify what exceptions a function may throw. The only practical states to specify are: 1) does not throw 2) always throws 3) might throw What is thrown is not reliably computable. For example: import foo; void test() { foo.bar(); } What exceptions does test() throw? That would require knowledge of the import foo, which is not necessarily knowable and can change over time.
Feb 21 2008
Walter Bright wrotewhich is not necessarily knowable and can change over timeThis holds also for the reduction to the three states Always, Never, Sometimes. -manfred
Feb 21 2008
Manfred Nowak wrote:Walter Bright wroteIf they are part of the type signature, then it can be enforced.which is not necessarily knowable and can change over timeThis holds also for the reduction to the three states Always, Never, Sometimes.
Feb 21 2008
Walter Bright wrote:If they are part of the type signature, then it can be enforced.For this one would have to ensure that the prerequisites of Rice's Theorem [http://en.wikipedia.org/wiki/Rice's_theorem] do not hold. How to do that? -manfred
Feb 21 2008
Manfred Nowak wrote:Walter Bright wrote:Don't have to compute it, just check it since it's part of the type signature.If they are part of the type signature, then it can be enforced.For this one would have to ensure that the prerequisites of Rice's Theorem [http://en.wikipedia.org/wiki/Rice's_theorem] do not hold. How to do that?
Feb 22 2008
Walter Bright wrote:Don't have to compute it, just check it since it's part of the type signature.Enforcing, checking but not computing? I don't get that. So I'll have to wait for the docs for "nothrow". -manfred
Feb 22 2008
Manfred Nowak schrieb:Walter Bright wrote:If you specify that some function does not throw an exception, you can enforce that simply by disallowing the use of "throw", as well as the use of any function which does not specify "nothrow" inside of the function. I'd guess thats how it's supposed to work. With this system, there would of course be some functions, which could never throw an exception, but are not allowed to carry the nothrow flag, however (i.e. a function which catches all the exceptions of all used functions).Don't have to compute it, just check it since it's part of the type signature.Enforcing, checking but not computing? I don't get that. So I'll have to wait for the docs for "nothrow". -manfred
Feb 22 2008
Sönke Ludwig wrote:Manfred Nowak schrieb:According to the conference slides, it'll allow any function that just has a "catch exception". It does indeed support catches (i.e. the function itself can set up exception handlers, but callers needn't). Also be aware that "new" throws exceptions if there's no memory left.Walter Bright wrote:If you specify that some function does not throw an exception, you can enforce that simply by disallowing the use of "throw", as well as the use of any function which does not specify "nothrow" inside of the function. I'd guess thats how it's supposed to work. With this system, there would of course be some functions, which could never throw an exception, but are not allowed to carry the nothrow flag, however (i.e. a function which catches all the exceptions of all used functions).Don't have to compute it, just check it since it's part of the type signature.Enforcing, checking but not computing? I don't get that. So I'll have to wait for the docs for "nothrow". -manfred
Feb 22 2008
Manfred Nowak wrote:Walter Bright wrote:Yes.Don't have to compute it, just check it since it's part of the type signature.Enforcing, checking but not computing?I don't get that. So I'll have to wait for the docs for "nothrow".It would work just like "nothrow" does for C++.
Feb 22 2008
Walter Bright wrote:It would work just like "nothrow" does for C++.BTW, wasn't there one of your arguments to have no negation in keywords? Which would make "exfree" a better choice? -manfred
Feb 24 2008
Manfred Nowak wrote:Walter Bright wrote:Yes. But everyone knows what "nothrow" means.It would work just like "nothrow" does for C++.BTW, wasn't there one of your arguments to have no negation in keywords?Which would make "exfree" a better choice?
Feb 24 2008
On Sun, 24 Feb 2008 11:53:00 -0800, Walter Bright wrote:Manfred Nowak wrote:ROTFLMAO -- Derek Parnell Melbourne, Australia skype: derek.j.parnellWalter Bright wrote:Yes. But everyone knows what "nothrow" means.It would work just like "nothrow" does for C++.BTW, wasn't there one of your arguments to have no negation in keywords?
Feb 24 2008
It would work just like "nothrow" does for C++.Just checking - I hope this means that if a nothrow function actually DID try to throw an exception (by calling something that throws), compiler- generated code would trap it and terminate the program with an error message?
Feb 24 2008
Graham St Jack wrote:No, but it will try to detect errors at compile time.It would work just like "nothrow" does for C++.Just checking - I hope this means that if a nothrow function actually DID try to throw an exception (by calling something that throws), compiler- generated code would trap it and terminate the program with an error message?
Feb 24 2008
Walter Bright escribió:Graham St Jack wrote:Does this mean this will not compile: int foo(int[] someArray, int someIndex) nothrow { return someArray[someIndex]; } but this will: int foo(int[] someArray, int someIndex) nothrow { if (someIndex < someArray.length) { return someArray[someIndex]; } else { return -1; } }No, but it will try to detect errors at compile time.It would work just like "nothrow" does for C++.Just checking - I hope this means that if a nothrow function actually DID try to throw an exception (by calling something that throws), compiler- generated code would trap it and terminate the program with an error message?
Feb 25 2008
Ary Borenszweig wrote:Does this mean this will not compile: int foo(int[] someArray, int someIndex) nothrow { return someArray[someIndex]; } but this will: int foo(int[] someArray, int someIndex) nothrow { if (someIndex < someArray.length) { return someArray[someIndex]; } else { return -1; } }I don't know yet. But the idea is to do static checking of what can throw.
Feb 25 2008
On Mon, 25 Feb 2008 01:44:15 -0800, Walter Bright wrote:Ary Borenszweig wrote:It will be a good trick if you can pull it off. I don't see how it can be done without examining the source code of all the called functions, leaving us back where we started with throw specs. The C++ approach of a runtime check isn't perfect, but at least it can be done, and provides a more definite form of documentation than comments. If the static checks aren't done well enough and runtime checks aren't done at all, I would prefer to rely on comments.Does this mean this will not compile: int foo(int[] someArray, int someIndex) nothrow { return someArray[someIndex]; } but this will: int foo(int[] someArray, int someIndex) nothrow { if (someIndex < someArray.length) { return someArray[someIndex]; } else { return -1; } }I don't know yet. But the idea is to do static checking of what can throw.
Feb 25 2008
Graham St Jack wrote:It will be a good trick if you can pull it off. I don't see how it can be done without examining the source code of all the called functions, leaving us back where we started with throw specs. The C++ approach of a runtime check isn't perfect, but at least it can be done, and provides a more definite form of documentation than comments.Are you sure it does a runtime check for nothrow?If the static checks aren't done well enough and runtime checks aren't done at all, I would prefer to rely on comments.
Feb 25 2008
== Quote from Walter Bright (newshound1 digitalmars.com)'s articleGraham St Jack wrote:I think it depends on the compiler. The MS compiler, for example, ignores exception specs, except possibly for nothrow (it's been a while and I cant recall). However, isn't the app supposed to terminate if an exception is thrown from a nothrow routine? I don't have my copy of the spec handy or I'd check. SeanIt will be a good trick if you can pull it off. I don't see how it can be done without examining the source code of all the called functions, leaving us back where we started with throw specs. The C++ approach of a runtime check isn't perfect, but at least it can be done, and provides a more definite form of documentation than comments.Are you sure it does a runtime check for nothrow?
Feb 26 2008
On Mon, 25 Feb 2008 08:55:17 -0800, Walter Bright wrote:Graham St Jack wrote:g++ certainly does runtime checking. I'm sure it does no static checking at all. We use the throw() and throw(list-of-exceptions) specs all the time in our C++ code, relying on the runtime checking to tell us if we get it wrong. This is quite horrible compared to static checking, but it is a lot better than nothing, because we find out what exception was thrown and which throw-spec was violated. The vast majority of functions in our C++ code use an empty throw-spec, so if D had nothrow with some static checking plus a runtime check, I would be better off than I am now with C++. Of course I would be even better off if the static checking was complete, but that seems to be too tricky.It will be a good trick if you can pull it off. I don't see how it can be done without examining the source code of all the called functions, leaving us back where we started with throw specs. The C++ approach of a runtime check isn't perfect, but at least it can be done, and provides a more definite form of documentation than comments.Are you sure it does a runtime check for nothrow?If the static checks aren't done well enough and runtime checks aren't done at all, I would prefer to rely on comments.
Feb 26 2008
== Quote from Graham St Jack (Graham.StJack internode.on.net)'s articleOn Mon, 25 Feb 2008 08:55:17 -0800, Walter Bright wrote:The nice thing about offering nothrow only is that it implicitly marks any unlabeled routine as one that may throw an exception. The problem in C++ with explicit exception specs is those unlabeled routines--they can throw anything but they're also callable from nothrow routines because they might not actually throw anything. It's a mess. SeanGraham St Jack wrote:g++ certainly does runtime checking. I'm sure it does no static checking at all. We use the throw() and throw(list-of-exceptions) specs all the time in our C++ code, relying on the runtime checking to tell us if we get it wrong. This is quite horrible compared to static checking, but it is a lot better than nothing, because we find out what exception was thrown and which throw-spec was violated. The vast majority of functions in our C++ code use an empty throw-spec, so if D had nothrow with some static checking plus a runtime check, I would be better off than I am now with C++. Of course I would be even better off if the static checking was complete, but that seems to be too tricky.It will be a good trick if you can pull it off. I don't see how it can be done without examining the source code of all the called functions, leaving us back where we started with throw specs. The C++ approach of a runtime check isn't perfect, but at least it can be done, and provides a more definite form of documentation than comments.Are you sure it does a runtime check for nothrow?
Feb 26 2008
On Wed, 27 Feb 2008 00:47:00 +0000, Sean Kelly wrote:== Quote from Graham St Jack (Graham.StJack internode.on.net)'s articleAgreed.On Mon, 25 Feb 2008 08:55:17 -0800, Walter Bright wrote:The nice thing about offering nothrow only is that it implicitly marks any unlabeled routine as one that may throw an exception. The problem in C++ with explicit exception specs is those unlabeled routines--they can throw anything but they're also callable from nothrow routines because they might not actually throw anything. It's a mess. SeanGraham St Jack wrote:g++ certainly does runtime checking. I'm sure it does no static checking at all. We use the throw() and throw(list-of-exceptions) specs all the time in our C++ code, relying on the runtime checking to tell us if we get it wrong. This is quite horrible compared to static checking, but it is a lot better than nothing, because we find out what exception was thrown and which throw-spec was violated. The vast majority of functions in our C++ code use an empty throw-spec, so if D had nothrow with some static checking plus a runtime check, I would be better off than I am now with C++. Of course I would be even better off if the static checking was complete, but that seems to be too tricky.It will be a good trick if you can pull it off. I don't see how it can be done without examining the source code of all the called functions, leaving us back where we started with throw specs. The C++ approach of a runtime check isn't perfect, but at least it can be done, and provides a more definite form of documentation than comments.Are you sure it does a runtime check for nothrow?
Feb 26 2008
Walter Bright wrote:Graham St Jack wrote:IMHO, it would behoove the compiler to keep track of possible/potential exceptions a function can throw. (Just as well as (again, IMHO) it would behoove the compiler to keep track of functions that /potentially/ have side effects.) The workload for doing either defines a pattern, and doing the other is simply a repetition of the pattern. Therefore, doing both is not much more work than doing only one of these. In the optimal future, entering a function would give you information (not necessarily runtime, but definitely info when browsing the docs) on whether it potentially generates an exception/changes data. A year after this info is standard in the docs, several new ideas about Functional Programming will emerge, in D. (Ermmmm, new to D, anyway.) ----- Keeping track of these two things may be considered superfluous drudgery, but the potential benefits well outweigh the invested effort.It will be a good trick if you can pull it off. I don't see how it can be done without examining the source code of all the called functions, leaving us back where we started with throw specs. The C++ approach of a runtime check isn't perfect, but at least it can be done, and provides a more definite form of documentation than comments.Are you sure it does a runtime check for nothrow?If the static checks aren't done well enough and runtime checks aren't done at all, I would prefer to rely on comments.
Mar 03 2008
Georg Wrede wrote:Walter Bright wrote:There's a few problems with what you're asking for: - extern(D) - .di files - delegates - dynamic loading There's also the matter of executable bloat.Graham St Jack wrote:IMHO, it would behoove the compiler to keep track of possible/potential exceptions a function can throw. (Just as well as (again, IMHO) it would behoove the compiler to keep track of functions that /potentially/ have side effects.)It will be a good trick if you can pull it off. I don't see how it can be done without examining the source code of all the called functions, leaving us back where we started with throw specs. The C++ approach of a runtime check isn't perfect, but at least it can be done, and provides a more definite form of documentation than comments.Are you sure it does a runtime check for nothrow?If the static checks aren't done well enough and runtime checks aren't done at all, I would prefer to rely on comments.
Mar 03 2008
Caveat lector! Er, upon proofreading it dawned upon me: This post does NOT interest Walter or anybody else who is concerned with compiler issues, the laguage itself, or optimizing. (What, is that like everybody in this newsgroup??) BUT, it still is very relevant to the advancement of D. IDE developers, framework architects, and library programmers may want to read this. Christopher Wright wrote:Georg Wrede wrote:We probably should reverse the bookkeeping to what the function does /not/ throw. With that, the above things would all be classified as unknown, which translates to "no exception is guaranteed to not get thrown". (For recursive implications, see below.)IMHO, it would behoove the compiler to keep track of possible/potential exceptions a function can throw. (Just as well as (again, IMHO) it would behoove the compiler to keep track of functions that /potentially/ have side effects.)There's a few problems with what you're asking for: - extern(D) - .di files - delegates - dynamic loadingThere's also the matter of executable bloat.All of this is compile-time-only stuff. Once compiled, the code should "look like" code that's never heard of the issue. But it still does the Right Thing. To be more precise, we're not [here] interested in what a function throws, only in what it is guaranteed /not/ to throw. For example, an in-place string transformation would be guaranteed to not throw an out-of-memory exception. (Unless the programmer is an idiot, but that doesn't count here.) By the same token, anytime I write a function in my code, the result of what other functions it calls and which they call in their turn, can be drawn as a tree structure. If we had machine readable documentation on each of the leaves, telling us /what it will not throw/, we might go on to the function that uses the leaf, see if it creates new kinds of exceptions and whether it may throw the new ones or any existing exceptions, and then compute the Set Intersection of the exceptions any of them /can not throw/. This gives us a guaranteed set of exceptions that /will not be thrown/ as a result of calling this (er...) Intermediate Node in the tree. By recursively applying this reasoning we ultimately end up with a hard document about my Brand New function, and what it doesn't throw. (( And as you pointed out earlier, anytime any of the leaves or the nodes uses any of: extern(D), .di files, delegates, dynamic loading; the entire tree gets tainted. That might actually be a shortcut from traversing the tree since we don't need any more information: NO EXCEPTION is guaranteed not to be thrown. )) While we're at it, this precisely same kind of analysis could be made about side effects. And even using precisely the same mechanics. All we need is data on the primary functions. Everything else is automatically computable from that. Including the library functions. (As in Phobos, etc.) The end result is, by the time we've written our own function, it is KNOWABLE what exceptions OUR function doesn't throw. And it is knowable whether our function DOES NOT create ANY side effects. The value of these two hardly need advertising. Functional programming, real-time stuff, robust code, secure code, the list goes on and on.
Mar 07 2008
Graham St Jack wrote:It will be a good trick if you can pull it off. I don't see how it can be done without examining the source code of all the called functions, leaving us back where we started with throw specs.I think the idea would be that nothrow is part of the function signature and a nothrow function can only call other nothrow functions or wrap any function calls or news in a catch(Exception) (since there's no way to know specifically which exceptions could be thrown).
Feb 26 2008
On Tue, 26 Feb 2008 23:36:34 -0800, Robert Fraser wrote:Graham St Jack wrote:That would work, but my feeling is that it would be so restrictive that hardly any functions could be nothrow.It will be a good trick if you can pull it off. I don't see how it can be done without examining the source code of all the called functions, leaving us back where we started with throw specs.I think the idea would be that nothrow is part of the function signature and a nothrow function can only call other nothrow functions or wrap any function calls or news in a catch(Exception) (since there's no way to know specifically which exceptions could be thrown).
Feb 27 2008
Robert Fraser wrote:Graham St Jack wrote:Yes. Therefore, the compiler has to know which functions are "nothrow", at compile time. Keeping track of this would be a lot of work -- ONE single time when implementing the bokkeeping of it. Later, the compiler programmer (Walter?) would only have to deal with this when creating totally new basic functions or severely altering the existing ones. And at that time it would not feel like a lot of work. Probably it would be like filling in a few items on a row in a (sql-like) table of function properties for the compiler.It will be a good trick if you can pull it off. I don't see how it can be done without examining the source code of all the called functions, leaving us back where we started with throw specs.I think the idea would be that nothrow is part of the function signature and a nothrow function can only call other nothrow functions or wrap any function calls or news in a catch(Exception) (since there's no way to know specifically which exceptions could be thrown).
Mar 03 2008
On Mon, 25 Feb 2008 12:44:15 +0300, Walter Bright = <newshound1 digitalmars.com> wrote:Ary Borenszweig wrote:Does this mean this will not compile: int foo(int[] someArray, int someIndex) nothrow { return someArray[someIndex]; } but this will: int foo(int[] someArray, int someIndex) nothrow { if (someIndex < someArray.length) { return someArray[someIndex]; } else { return -1; } }I don't know yet. But the idea is to do static checking of what can =throw.Just my $0.02 about nothrow and DesignByContract: I think that nothrow a= re = incompatible with DbC. A function/method could have contracts or nothrow= = but not both of them. It is especially actual for virtual (non-final) = methods. Suppose that some class has: class A { public void cleanup() nothrow { ... }; } so it could be safely used in 'finally' statement: A someResource =3D acquireResource(); try { ... /* some processing */ ... } finally { someResource.cleanup; /* looks like exception-safe action */ } But if there is a derived class B, which overrides cleanup() with = postcondition: class B : A { public void cleanup() nothrow out { ... some checking ... } body { ... some actions ... } } and acquireResource() would return B instead of A, then the code above = won't be exception-safe. Moreover the behaviour of 'someResource.cleanup= ' = would depend on compiler switches. -- = Regards, Yauheni Akhotnikau
Feb 25 2008
eao197 wrote:On Mon, 25 Feb 2008 12:44:15 +0300, Walter Bright <newshound1 digitalmars.com> wrote:So the code generated depends on compiler switches... Isn't this always true? The "nothrow" spec could only actually be used when building release mode, and in non-release mode code, exception handling frames are always set up. This means that nothrow functions can still use assert() and array indexing without worries, since these only throw exceptions in non-release-mode code. Of course, then problems occur when mixing code compiled with different switches...Ary Borenszweig wrote:Just my $0.02 about nothrow and DesignByContract: I think that nothrow are incompatible with DbC. A function/method could have contracts or nothrow but not both of them. It is especially actual for virtual (non-final) methods. Suppose that some class has: class A { public void cleanup() nothrow { ... }; } so it could be safely used in 'finally' statement: A someResource = acquireResource(); try { ... /* some processing */ ... } finally { someResource.cleanup; /* looks like exception-safe action */ } But if there is a derived class B, which overrides cleanup() with postcondition: class B : A { public void cleanup() nothrow out { ... some checking ... } body { ... some actions ... } } and acquireResource() would return B instead of A, then the code above won't be exception-safe. Moreover the behaviour of 'someResource.cleanup' would depend on compiler switches.Does this mean this will not compile: int foo(int[] someArray, int someIndex) nothrow { return someArray[someIndex]; } but this will: int foo(int[] someArray, int someIndex) nothrow { if (someIndex < someArray.length) { return someArray[someIndex]; } else { return -1; } }I don't know yet. But the idea is to do static checking of what can throw.
Feb 26 2008
On Wed, 27 Feb 2008 10:42:07 +0300, Robert Fraser = <fraserofthenight gmail.com> wrote:eao197 wrote:On Mon, 25 Feb 2008 12:44:15 +0300, Walter Bright ==<newshound1 digitalmars.com> wrote:Ary Borenszweig wrote:Does this mean this will not compile: int foo(int[] someArray, int someIndex) nothrow { return someArray[someIndex]; } but this will: int foo(int[] someArray, int someIndex) nothrow { if (someIndex < someArray.length) { return someArray[someIndex]; } else { return -1; } }I don't know yet. But the idea is to do static checking of what can =ow =throw.Just my $0.02 about nothrow and DesignByContract: I think that nothr==are incompatible with DbC. A function/method could have contracts or =nothrow but not both of them. It is especially actual for virtual =(non-final) methods. Suppose that some class has: class A { public void cleanup() nothrow { ... }; } so it could be safely used in 'finally' statement: A someResource =3D acquireResource(); try { ... /* some processing */ ... } finally { someResource.cleanup; /* looks like exception-safe action */ } But if there is a derived class B, which overrides cleanup() with =ve =postcondition: class B : A { public void cleanup() nothrow out { ... some checking ... } body { ... some actions ... } } and acquireResource() would return B instead of A, then the code abo=won't be exception-safe. Moreover the behaviour of =s ='someResource.cleanup' would depend on compiler switches.So the code generated depends on compiler switches... Isn't this alway=true? The "nothrow" spec could only actually be used when building =release mode, and in non-release mode code, exception handling frames ==are always set up. This means that nothrow functions can still use =assert() and array indexing without worries, since these only throw =exceptions in non-release-mode code. Of course, then problems occur when mixing code compiled with differen=t =switches...I'm affraid that you misunderstand my point. When you use a[i] or new in= = nothrow function you always known what could happen. But if you call = virtual method from any object you can't predict its behaviour. Because = = the method implementation in some derived class could define contract fo= r = that method. And you may don't known about it. And becouse of this I think that 'nothrow' is a kind of function contrac= t. = And if a function defines such contract then it can't redefine it in = derived classes. -- = Regards, Yauheni Akhotnikau
Feb 27 2008
eao197 escribió:But contracts are predictable. Say B extends A, and A has a foo method. If foo says nothrow, than if B overrides foo, it must also be nothrow (this will be enforced by the compiler, I'm sure). For in and out, http://www.digitalmars.com/d/1.0/dbc.html shows there will be no problem.eao197 wrote:I'm affraid that you misunderstand my point. When you use a[i] or new in nothrow function you always known what could happen. But if you call virtual method from any object you can't predict its behaviour. Because the method implementation in some derived class could define contract for that method. And you may don't known about it. And becouse of this I think that 'nothrow' is a kind of function contract. And if a function defines such contract then it can't redefine it in derived classes.
Feb 27 2008
On Wed, 27 Feb 2008 12:40:03 +0300, Ary Borenszweig <ary esperanto.org.ar> wrote:eao197 escribió:B.foo may looks like: void foo() nothrow in { assert( <some condition> ); } out { assert( <some condition> ); } body { <some code without exception> } Body of B.foo() doesn't throw exception but assert in pre/postcondition could do that. A call of B.foo could produce exception but B.foo is declared as 'nothrow' :( -- Regards, Yauheni AkhotnikauBut contracts are predictable. Say B extends A, and A has a foo method. If foo says nothrow, than if B overrides foo, it must also be nothrow (this will be enforced by the compiler, I'm sure).eao197 wrote:I'm affraid that you misunderstand my point. When you use a[i] or new in nothrow function you always known what could happen. But if you call virtual method from any object you can't predict its behaviour. Because the method implementation in some derived class could define contract for that method. And you may don't known about it. And becouse of this I think that 'nothrow' is a kind of function contract. And if a function defines such contract then it can't redefine it in derived classes.
Feb 27 2008
eao197 wrote:B.foo may looks like: void foo() nothrow in { assert( <some condition> ); } out { assert( <some condition> ); } body { <some code without exception> } Body of B.foo() doesn't throw exception but assert in pre/postcondition could do that. A call of B.foo could produce exception but B.foo is declared as 'nothrow' :(I'm happy with that. Contracts aren't compiled in release mode, and they aren't part of the function; they're part of the tests. I'd hate to have to avoid one language feature for reliability in order to gain another one.
Feb 27 2008
On Wed, 27 Feb 2008 16:56:34 +0300, Christopher Wright <dhasenan gmail.com> wrote:eao197 wrote:People are different. You want to compile your programs in release mode to remove any run-time checks and contracts. I want to save them in my programs to catch errors at the most earliest stage ('fail fast' principle is very important in server-side systems). But a programing language must provide logical and consistent rules for each of us. -- Regards, Yauheni AkhotnikauB.foo may looks like: void foo() nothrow in { assert( <some condition> ); } out { assert( <some condition> ); } body { <some code without exception> } Body of B.foo() doesn't throw exception but assert in pre/postcondition could do that. A call of B.foo could produce exception but B.foo is declared as 'nothrow' :(I'm happy with that. Contracts aren't compiled in release mode, and they aren't part of the function; they're part of the tests. I'd hate to have to avoid one language feature for reliability in order to gain another one.
Feb 27 2008
I wonder if asserts() should be the exception to nothrow. Like eao197, I normally run my programs with assert()s turned on. But it would be a shame to lose nothrow because of that. Are assert()s catchable? Other than in some sort of weird systems programming context (where you are running one program inside another), why would you want to catch them? (I'm sure somebody has a compelling example...but would that example be ruined by asserts-that-penetrate-nothrow.) eao197 wrote:On Wed, 27 Feb 2008 16:56:34 +0300, Christopher Wright <dhasenan gmail.com> wrote:eao197 wrote:People are different. You want to compile your programs in release mode to remove any run-time checks and contracts. I want to save them in my programs to catch errors at the most earliest stage ('fail fast' principle is very important in server-side systems). But a programing language must provide logical and consistent rules for each of us. --Regards, Yauheni AkhotnikauB.foo may looks like: void foo() nothrow in { assert( <some condition> ); } out { assert( <some condition> ); } body { <some code without exception> } Body of B.foo() doesn't throw exception but assert in pre/postcondition could do that. A call of B.foo could produce exception but B.foo is declared as 'nothrow' :(I'm happy with that. Contracts aren't compiled in release mode, and they aren't part of the function; they're part of the tests. I'd hate to have to avoid one language feature for reliability in order to gain another one.
Feb 27 2008
On Thu, 28 Feb 2008 07:27:24 +0300, Russell Lewis = <webmaster villagersonline.com> wrote:I wonder if asserts() should be the exception to nothrow. Like eao197=, =I normally run my programs with assert()s turned on. But it would be =a =shame to lose nothrow because of that. Are assert()s catchable?Yes, it is catchable: import std.stdio; import std.asserterror; void do_something( int i, int j ) in { assert( i < j, "i must be lesser than j" ); } body { writefln( "i=3D", i, ", j=3D", j ); } void main() { try { do_something( 0, 1 ); do_something( 1, 0 ); } catch( AssertError x ) { writefln( x ); } }Other than in some sort of weird systems programming context (where yo=u =are running one program inside another), why would you want to catch =them?It is not necessary to catch AssertError. Sometimes it is necessary to = catch any error. For example, in a HTTP-server you could start processin= g = of a new request and catch different kinds of errors to make appropriate= = response: void processNewRequest( SomeRequestData request ) { try { requestProcessingActions( request ); } catch( Error x ) { logError( x ); classifyErrorAndMakeAppropriateResponse( x ); } } There is no difference between some application-logic error, index out o= f = range error, no memory error or AssertError. The request processing fail= ed = and the reason must be logged.(I'm sure somebody has a compelling example...but would that example =be =ruined by asserts-that-penetrate-nothrow.)May be I don't understand your question, but I think that nothrow should= = help write exception-safe code. For example, some resource cleanup actio= ns = in finally statements: auto firstStream =3D createStream(); auto secondStream =3D createStream(); auto thirdStream =3D createStream(); try { firstStream.open( 'first' ); secondStream.open( 'second' ); thirdStream.open( 'third' ); ... some actions with firstStream, secondStream and thirdStream ... } finally { // All stream should be closed here. firstStream.close; secondStream.close; thirdStream.close; ... some other cleanup code... } It is rather naive resource cleanup code, because without nothrow = specification we can't assume that a 'close' call doesn't throw an = exception. If close can throw exceptions we must rewrite it, for example= : finally { void safeClose( Stream s ) { try { s.close; } catch( Error ) {} } safeClose( firstStream ); safeClose( secondStream ); safeClose( thirdStream ); ... some other cleanup code... } But if we know that close doesn't throw exceptions then we can write les= s = code (without safeClose helper function). And I suppose that 'nothrow' i= s = a promise of function's developer that the function doesn't throw an = exception. But if 'close' is written as: close() nothrow in { assert( is_opened(), "close() must be called only in stream is = open" ); } body { ... } I think that such implementation brokes a promise about non-throwing = exception. For example, what if some exception is thrown at = secondStream.open("second") in the sample above? We are going to finally= = statement, successfully close firstStream, but get AssertError at = secondStream.close(). It breaks finally statement and we have no chance = to = perform other cleanup code. So I think that nothrow is a contract which is violated by any assert in= = in/out statements. And because of that nothrow shouldn't be used with = in/out contracts. But here is another kind of problem with nothrow. I don't know is it = possible to write really exception free code in D (AFAIK it is impossibl= e = on JVM/.NET because VM could raise some of it internal exception at any = = moment). Exceptions could be everywere -- on accessing array items, on = string concatenations, on new statements, on calling some functions with= = pre/postconditions and so on. So probably nothrow function could throw = some kind of exceptions even if function's writter don't known about the= m = (it reminds me unchecked exceptions in Java which could be thrown despit= e = of method's exception specification). In such case AssertError could be = = one of such 'unchecked exception' in D, and in such case nothrow could b= e = combined with in/out statements. But in such case the profit from nothro= w = is under doubt for me. Disclaimer: I know that my sample with streams and resource cleanup in = finally statement could be rewritten in different ways. It is just a = sample.eao197 wrote:On Wed, 27 Feb 2008 16:56:34 +0300, Christopher Wright =<dhasenan gmail.com> wrote:eao197 wrote:B.foo may looks like: void foo() nothrow in { assert( <some condition> ); } out { assert( <some condition> ); } body { <some code without exception> } Body of B.foo() doesn't throw exception but assert in =pre/postcondition could do that. A call of B.foo could produce ==exception but B.foo is declared as 'nothrow' :(I'm happy with that. Contracts aren't compiled in release mode, and =e =they aren't part of the function; they're part of the tests. I'd hat=in =to have to avoid one language feature for reliability in order to ga=another one.People are different. You want to compile your programs in release ==mode to remove any run-time checks and contracts. I want to save them=' =in my programs to catch errors at the most earliest stage ('fail fast==principle is very important in server-side systems). But a programing=-- = Regards, Yauheni Akhotnikaulanguage must provide logical and consistent rules for each of us. --Regards, Yauheni Akhotnikau
Feb 28 2008
eao197 wrote:On Thu, 28 Feb 2008 07:27:24 +0300, Russell Lewis <webmaster villagersonline.com> wrote:(snip)I wonder if asserts() should be the exception to nothrow. Like eao197, I normally run my programs with assert()s turned on. But it would be a shame to lose nothrow because of that. Are assert()s catchable?Yes, it is catchable:I agree that a web server needs to post an appropriate response. But if an assert() has failed, you don't know if the failure is in your main program, in a library, or maybe even in your network code. In that case, you can't really rely on your program to keep working correctly, and the only sane solution would be to restart it. My argument, then, is that you need a metaprogram or "watchdog" (such as the init process in *NIX, or maybe just a "web server launcher") which manages the server programs and restarts them when they crash.Other than in some sort of weird systems programming context (where you are running one program inside another), why would you want to catch them?It is not necessary to catch AssertError. Sometimes it is necessary to catch any error. For example, in a HTTP-server you could start processing of a new request and catch different kinds of errors to make appropriate response:There is no difference between some application-logic error, index out of range error, no memory error or AssertError. The request processing failed and the reason must be logged.From the web client's or the system administrator's perspective, I agree. The error should be reported to the client, and logged for the admin. But from the internal-consistency-of-the-program perspective, these are very different. An out-of-memory error is a (possibly transient) memory issue. The internal logic of the program is intact. Array index out of range might (or might not) be survivable. But a failed assert() means that something is (or might be) deeply wrong with the internal logic of the program. That's not something, IMHO, that you ought to try to catch and then forget. Things which are recoverable should throw Exceptions. Things which are fatal should fail assert()s.
Feb 28 2008
On Thu, 28 Feb 2008 19:34:45 +0300, Russell Lewis = <webmaster villagersonline.com> wrote:to =It is not necessary to catch AssertError. Sometimes it is necessary =catch any error. For example, in a HTTP-server you could start =ke =processing of a new request and catch different kinds of errors to ma=if =appropriate response:I agree that a web server needs to post an appropriate response. But =an assert() has failed, you don't know if the failure is in your main ==program, in a library, or maybe even in your network code. In that =case, you can't really rely on your program to keep working correctly,==and the only sane solution would be to restart it.Violation of contract is not a sign of unrecoverable failure of the = program, expecially for preconditions. Quite the contrary contracts help= = detect unappropriate conditions at earlier stages. For example, SMS body in 140 bytes long. 7-bit message could be up to 16= 0 = symbols, packed into 140 bytes SMS body. You could have 7-bit message = packing functions with precondition: byte[] pack7bitMessage( byte[] message ) in { assert( message.length <=3D 160 ); } body { ... } When pack7bitMessage receives message which is longer than 160 symbols = there isn't any sign of unrecoverable error. For example, the too long = body of message may be received from SMPP PDU submit_sm from a ESME who = = simply had made an error in their PDU. It may be a sign of presence of = error in your code for submit_sm parsing (length of SMS body not checked= ) = but there nothing fatal for whole application. And that is a situation where application abort and restart don't solve = a = problem -- ESME simply repeat the problem submit_sm after server restart= = and server go down again and so on.My argument, then, is that you need a metaprogram or "watchdog" (such =as =the init process in *NIX, or maybe just a "web server launcher") which==manages the server programs and restarts them when they crash.A rather complex application is build from a several layers. A failure o= n = some layer should abort all current processing on that layer, but parent= = layer could restart the problem layer. So that model with = metaprogram/watchdogs or supervisor processes (from Erlang) could be = implemented inside a single application with use of safe languages like = D, = -- = Regards, Yauheni Akhotnikau
Feb 29 2008
It seems that we have a significant programming style difference. Let me explain and advocate for my style... I believe that assert()s are ways to programmatically document things that the program must enforce. An in() contract on a function is a statement that says "any code which calls me, but violates this contract, is buggy." Exceptions are the way to programmatically handle unusual conditions in well-ordered ways. So, in your example below, since pack7bitMessage asserts that the message must be no more than 160 characters, then any code which called it must enforce that contract. Any code which didn't enforce the contract has a bug. IMHO, if what you want is to have a function which will take input of any length, but refuse to encode things which are longer than 160 characters, then it should be coded as follows: byte[] pack7bitMessage( byte[] message ) { if(message.length > 160) throw InputTooLongException; ... encode ... } This is why I argued that assert()s are unrecoverable errors and exceptions are reasonably recoverable. Finally, let me ask you a question: If an failed assert() doesn't represent an unrecoverable logic error, then what does??? eao197 wrote:On Thu, 28 Feb 2008 19:34:45 +0300, Russell Lewis <webmaster villagersonline.com> wrote:Violation of contract is not a sign of unrecoverable failure of the program, expecially for preconditions. Quite the contrary contracts help detect unappropriate conditions at earlier stages. For example, SMS body in 140 bytes long. 7-bit message could be up to 160 symbols, packed into 140 bytes SMS body. You could have 7-bit message packing functions with precondition: byte[] pack7bitMessage( byte[] message ) in { assert( message.length <= 160 ); } body { ... } When pack7bitMessage receives message which is longer than 160 symbols there isn't any sign of unrecoverable error. For example, the too long body of message may be received from SMPP PDU submit_sm from a ESME who simply had made an error in their PDU. It may be a sign of presence of error in your code for submit_sm parsing (length of SMS body not checked) but there nothing fatal for whole application. And that is a situation where application abort and restart don't solve a problem -- ESME simply repeat the problem submit_sm after server restart and server go down again and so on.It is not necessary to catch AssertError. Sometimes it is necessary to catch any error. For example, in a HTTP-server you could start processing of a new request and catch different kinds of errors to make appropriate response:I agree that a web server needs to post an appropriate response. But if an assert() has failed, you don't know if the failure is in your main program, in a library, or maybe even in your network code. In that case, you can't really rely on your program to keep working correctly, and the only sane solution would be to restart it.My argument, then, is that you need a metaprogram or "watchdog" (such as the init process in *NIX, or maybe just a "web server launcher") which manages the server programs and restarts them when they crash.A rather complex application is build from a several layers. A failure on some layer should abort all current processing on that layer, but parent layer could restart the problem layer. So that model with metaprogram/watchdogs or supervisor processes (from Erlang) could be implemented inside a single application with use of safe languages like --Regards, Yauheni Akhotnikau
Feb 29 2008
On Fri, 29 Feb 2008 18:42:05 +0300, Russell Lewis = <webmaster villagersonline.com> wrote:I believe that assert()s are ways to programmatically document things ==that the program must enforce. An in() contract on a function is a =statement that says "any code which calls me, but violates this =contract, is buggy." Exceptions are the way to programmatically handl=e =unusual conditions in well-ordered ways.Contract may be considered another way: a function with precodition says= = "I guarantee correct behaviour only when you keeps my precondition".So, in your example below, since pack7bitMessage asserts that the =message must be no more than 160 characters, then any code which calle=d =it must enforce that contract. Any code which didn't enforce the =contract has a bug.Yes it is. But a bug in code is not always should lead to abortion of = entire application.IMHO, if what you want is to have a function which will take input of ==any length, but refuse to encode things which are longer than 160 =characters, then it should be coded as follows: byte[] pack7bitMessage( byte[] message ) { if(message.length > 160) throw InputTooLongException; ... encode ... }Yes that function could be rewritten in such way. But there could be = condition when DbC is preferable than defensive programming: - contracts are part of function prototype, so conract help understandin= g = function behaviour. For example, try look at EiffelBase reference manual= = (http://docs.eiffel.com) -- sometimes bodies of 'require' and 'ensure' = give more information that description of a methods; - contracts could be turned off in release mode when you sure that there= = isn't critical bugs. So, function with contracts: byte[] pack7bitMessage( byte[] message ) in { assert( message ); assert( message.length <=3D 160 ); assert( !is8bitCharFound( message ) ); } body { ... } will be much faster in speed-critical applications then the function whi= ch = is written in defensive-programming style.Finally, let me ask you a question: If an failed assert() doesn't represent an unrecoverable logic error, ==then what does???As in the case with ordinal exception -- it depends. When you try to add= a = member into associative array you and get NoMemory exception you don't = know is that exception would be unrecoverable or recoverable. If you wri= te = yet another WordCounter example such exception will be fatal for your = application. But if you write, for example, some image-transformation = program for http://picasa.google.com/ you could simple throw away curren= t = problematic image, clear all resouces which was allocated for that image= , = and go to next image in queue.eao197 wrote:On Thu, 28 Feb 2008 19:34:45 +0300, Russell Lewis =y =<webmaster villagersonline.com> wrote:It is not necessary to catch AssertError. Sometimes it is necessar=to catch any error. For example, in a HTTP-server you could start ==processing of a new request and catch different kinds of errors to =t =make appropriate response:I agree that a web server needs to post an appropriate response. Bu==if an assert() has failed, you don't know if the failure is in your ==main program, in a library, or maybe even in your network code. In =that case, you can't really rely on your program to keep working ==correctly, and the only sane solution would be to restart it.Violation of contract is not a sign of unrecoverable failure of the =program, expecially for preconditions. Quite the contrary contracts =o =help detect unappropriate conditions at earlier stages. For example, SMS body in 140 bytes long. 7-bit message could be up t=160 symbols, packed into 140 bytes SMS body. You could have 7-bit =ls =message packing functions with precondition: byte[] pack7bitMessage( byte[] message ) in { assert( message.length <=3D 160 ); } body { ... } When pack7bitMessage receives message which is longer than 160 symbo=g =there isn't any sign of unrecoverable error. For example, the too lon=ho =body of message may be received from SMPP PDU submit_sm from a ESME w=f =simply had made an error in their PDU. It may be a sign of presence o=error in your code for submit_sm parsing (length of SMS body not =checked) but there nothing fatal for whole application. And that is a situation where application abort and restart don't =solve a problem -- ESME simply repeat the problem submit_sm after =h =server restart and server go down again and so on.My argument, then, is that you need a metaprogram or "watchdog" (suc==as the init process in *NIX, or maybe just a "web server launcher") =which manages the server programs and restarts them when they crash.=re =A rather complex application is build from a several layers. A failu==on some layer should abort all current processing on that layer, but =parent layer could restart the problem layer. So that model with ==metaprogram/watchdogs or supervisor processes (from Erlang) could be =ke =implemented inside a single application with use of safe languages li=-- = Regards, Yauheni Akhotnikau--Regards, Yauheni Akhotnikau
Feb 29 2008
eao197 wrote:On Thu, 28 Feb 2008 19:34:45 +0300, Russell Lewis <webmaster villagersonline.com> wrote:...It is not necessary to catch AssertError. Sometimes it is necessary to catch any error. For example, in a HTTP-server you could start processing of a new request and catch different kinds of errors to make appropriate response:I agree that a web server needs to post an appropriate response. But if an assert() has failed, you don't know if the failure is in yourFor example, SMS body in 140 bytes long. 7-bit message could be up to 160 symbols, packed into 140 bytes SMS body. You could have 7-bit message packing functions with precondition: byte[] pack7bitMessage( byte[] message ) in { assert( message.length <= 160 ); } body { ... }... I think you are misunderstanding the purpose of assert and of other conditions. Remember, these statements will be stripped out of the code when it is compiled for release. As such, they should only be used to detect conditions which are genuine errors. The reason that they might be cause would be so that the actual error could be raised from the location where the error is generated, rather than from where it was detected. In Other Words: Don't use contracts as a substitute for conditionals, even if the conditional *would* raise an exception. They aren't the same concept. Now I'll grant that in some languages the two concepts are fused, and conditionals are constrained to do double duty as exceptions. Even in those languages, however, there is often a flag that will cause assertions to become null statements when compiled with optimization (or without debugging turned on). [N.B.: The prior paragraph is based on certain dialects of C or C++ that are over a decade old now. It may not apply to currently extant compilers.]
Feb 29 2008
The example would be (reasonably) compilable, without whole-program knowledege, if foo() had an in{} condition which asserted that the index was valid. It would be possible (though not trivial) for the compiler to say "ah, provided that the caller follows the in{} contract, this function cannot throw an exception." Walter Bright wrote:Ary Borenszweig wrote:Does this mean this will not compile: int foo(int[] someArray, int someIndex) nothrow { return someArray[someIndex]; } but this will: int foo(int[] someArray, int someIndex) nothrow { if (someIndex < someArray.length) { return someArray[someIndex]; } else { return -1; } }I don't know yet. But the idea is to do static checking of what can throw.
Feb 25 2008
Ary Borenszweig wrote:Walter Bright escribió:I sincerely hope that design by contract will allow for us to iron out issues like this. Ideally, something very near the following should be valid: int foo(int[] someArray, int someIndex) nothrow in{ assert(someIndex < someArray.length && someIndex >= 0); } body{ return someArray[someIndex]; } I've always hoped for in and out contracts to be usable by the compiler for optimization (such as verifying nothrow). I know this looks like it violates the nothrow (when not compiled with the release flag), but I'm ok with that for code I'm debugging. Printing the failed assert and ending the program is more useful to me anyway.Graham St Jack wrote:Does this mean this will not compile: int foo(int[] someArray, int someIndex) nothrow { return someArray[someIndex]; }No, but it will try to detect errors at compile time.It would work just like "nothrow" does for C++.Just checking - I hope this means that if a nothrow function actually DID try to throw an exception (by calling something that throws), compiler- generated code would trap it and terminate the program with an error message?
Feb 25 2008
Walter Bright wrote:Graham St Jack wrote:And nothrow will be a valid part of a delegate signature, correct? So I can use nothrow with delegates. Nothrow is especially tricky because it doesn't require a function call to get an exception. But those cases are relatively rare.No, but it will try to detect errors at compile time.It would work just like "nothrow" does for C++.Just checking - I hope this means that if a nothrow function actually DID try to throw an exception (by calling something that throws), compiler- generated code would trap it and terminate the program with an error message?
Feb 25 2008
Walter Bright, el 20 de febrero a las 18:58 me escribiste:Graham St Jack wrote:And what's the difference with nothrow? foo.bar's nothrow-ness "is not necessarily knowable and can change over time". It's exactly the same, you're just limiting the way you specify exceptions, but you are specifing them after all. This is like limiting C++ exception specification to nothing or an empty throw() qualifier. -- Leandro Lucarella (luca) | Blog colectivo: http://www.mazziblog.com.ar/blog/ ---------------------------------------------------------------------------- GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145 104C 949E BFB6 5F5A 8D05) ---------------------------------------------------------------------------- Hace diez años tenÃa una visión Pero nadie más la vió y hoy sigo pidiendo perdónIt is also very helpful when writing code to know that a function you are calling won't throw an exception - it means you have three kinds of functions: those that don't throw, those with comments telling you what they throw, and those that you need to fix the comments for.Experience with this indicates that it is impractical to specify what exceptions a function may throw. The only practical states to specify are: 1) does not throw 2) always throws 3) might throw What is thrown is not reliably computable. For example: import foo; void test() { foo.bar(); } What exceptions does test() throw? That would require knowledge of the import foo, which is not necessarily knowable and can change over time.
Feb 25 2008
Leandro Lucarella wrote:Walter Bright, el 20 de febrero a las 18:58 me escribiste:Of course, there should be a Nothrow-offense exception. Right?!! Such an exception would be thrown whenever a function that's declared as not throwing an exception actually does throw one.Graham St Jack wrote:And what's the difference with nothrow? foo.bar's nothrow-ness "is not necessarily knowable and can change over time". It's exactly the same, you're just limiting the way you specify exceptions, but you are specifing them after all. This is like limiting C++ exception specification to nothing or an empty throw() qualifier.It is also very helpful when writing code to know that a function you are calling won't throw an exception - it means you have three kinds of functions: those that don't throw, those with comments telling you what they throw, and those that you need to fix the comments for.Experience with this indicates that it is impractical to specify what exceptions a function may throw. The only practical states to specify are: 1) does not throw 2) always throws 3) might throw What is thrown is not reliably computable. For example: import foo; void test() { foo.bar(); } What exceptions does test() throw? That would require knowledge of the import foo, which is not necessarily knowable and can change over time.
Mar 03 2008
Extrawurst wrote:yeah but what happend to the express-such-things-via-documention policy to keep syntax simple ?It looks like the bane of all my Java existence, exception specifications, are back, under the mask of "optimization" this time. But, unlike const, you're not required to use nothrow to make use of libraries which use it, so it's up to you to ignore it or not.
Feb 21 2008
Robert Fraser escribió:Extrawurst wrote:In fact, it's just serves as a hint to the compiler, right? Like "inline" in C?yeah but what happend to the express-such-things-via-documention policy to keep syntax simple ?It looks like the bane of all my Java existence, exception specifications, are back, under the mask of "optimization" this time. But, unlike const, you're not required to use nothrow to make use of libraries which use it, so it's up to you to ignore it or not.
Feb 21 2008
Ary Borenszweig wrote:Robert Fraser escribió:In the slides from the conference it is mentioned that nothrow is statically checked by the compiler. I think it's not only about optimization, it's also useful for writing exception-safe code.Extrawurst wrote:In fact, it's just serves as a hint to the compiler, right? Like "inline" in C?yeah but what happend to the express-such-things-via-documention policy to keep syntax simple ?It looks like the bane of all my Java existence, exception specifications, are back, under the mask of "optimization" this time. But, unlike const, you're not required to use nothrow to make use of libraries which use it, so it's up to you to ignore it or not.
Feb 21 2008
Robert Fraser wrote:Extrawurst wrote:The downsides of general exception specifications are not shared by nothrow.yeah but what happend to the express-such-things-via-documention policy to keep syntax simple ?It looks like the bane of all my Java existence, exception specifications, are back, under the mask of "optimization" this time. But, unlike const, you're not required to use nothrow to make use of libraries which use it, so it's up to you to ignore it or not.
Feb 21 2008
Walter Bright wrote:http://www.digitalmars.com/d/2.0/changelog.html Now allow static arrays to be lvalues.Cool, and about time! :) I've just tried it out and it's so much more natural. -- Bruno Medeiros - MSc in CS/E student http://www.prowiki.org/wiki4d/wiki.cgi?BrunoMedeiros#D
Feb 28 2008