digitalmars.D - Few mixed things
- bearophile (29/32) Apr 21 2009 Few things I have collected in the last days.
- BCS (2/9) Apr 21 2009 you spotted the issue, code porting and principle of least surprise
- bearophile (7/8) Apr 21 2009 - Code porting: If you port C code to D, it uses /* */ in a non nested w...
- Andrei Alexandrescu (7/14) Apr 21 2009 No. This is valid C:
- Nick Sabalausky (9/17) Apr 21 2009 That seems like a rather trivial thing to be designing our language arou...
- BCS (2/28) Apr 21 2009 I'd be fine depricating /**/.
- Denis Koroskin (3/29) Apr 21 2009 You mean, deprecating /++/?
- BCS (4/8) Apr 21 2009 No, I mean exactly what I said.
- BCS (3/14) Apr 21 2009 I'd also be fine with doing nothing. What I'd not be fine with is making...
- Nick Sabalausky (4/12) Apr 21 2009 Are there any problems you see with it other than porting code to D? (FW...
- Paul D. Anderson (4/22) Apr 21 2009 I've seen lots of code that did that.
- Bill Baxter (10/31) Apr 21 2009 I could see (and maybe have seen?) people using it in comments:
- Nick Sabalausky (22/57) Apr 21 2009 Yea, but something like that would be trivial to notice and fix.
- Bill Baxter (15/75) Apr 21 2009 he
- Derek Parnell (6/12) Apr 21 2009 Yes, this is the legacy we now must keep.
- bearophile (4/5) Apr 22 2009 I am willing to modify the D2 code written by everyone before April 22 2...
- Derek Parnell (11/13) Apr 21 2009 The "well defined semantics" are not god-given axioms, or to rephrase it...
- Nick Sabalausky (5/14) Apr 21 2009 I agree with you on this, however I think what they meant was that (unle...
- Derek Parnell (8/11) Apr 21 2009 However, I regularly use the Progress language in which /* */ are nestab...
- BCS (5/28) Apr 22 2009 Precedent is a good reason to exist in /some given form/ if it is to exi...
- Derek Parnell (6/8) Apr 21 2009 "sometimes" !?
- Nick Sabalausky (4/9) Apr 21 2009 Well, I'm not always thinking about D! Sometimes I'm thinking about Star...
- Frits van Bommel (21/26) Apr 22 2009 Sometimes it's handy to have non-nesting comments.
Few things I have collected in the last days. Can RAND_MAX be added to std.c.stdlib of D1 too? ----------------------- What is the advantage of having a separate /+ +/ nestable comment syntax? Can't the /+ +/ be removed to make the normal /* */ syntax nestable? (IS the different C semantics of /* */ a problem here? I don't think so.) ----------------------- Using obj2asm to the .obj produced by D2 (v2.029) produced huge (like 100-600 KB!) asm files even for 10-lines long programs (The same asm files where very small for D1). There's a very large amount of asm code inside there. ----------------------- From the Python newsgroup:Linden Lab, makers of Second LIfe virtual world, found it was good to create a C++ class similar to a Python dictionary in order to leverage some of the faster prototyping advantages of that Python type when converting to C++.<LLSD is a proposed IETF standard so there's no licensing issues involved in using the technique, and I believe there are implementations in C++ (GPL) andLinden Lab Structured Data (LLSD) is an abstract type system intended to provide a language-neutral facility for the representation of structured data. It provides a type system, a serialization system and an interface description language.<http://wiki.secondlife.com/wiki/LLSD http://tools.ietf.org/id/draft-hamrick-llsd-00.txt ----------------------- The std.intrinsic module may gain a standard way to perform a 64-bit by 32-bit division, for the situations where you know the quotient will fit in 32 bits ('divl' instruction on X86). CPUs that don't support such operation can use the normal 64-big division. ----------------------- I don't like the way Ruby denotes intervals open/closed on the right. The following is how you do it in the Groovy language (but I don't like it, because I like intervals by default open on the right): Loop on closed on the right range: for (i in 0..n) Loop on open on the right range: for (i in 0..<n) Two possible syntaxes for D, to represent intervals closed on the right, using for (i; 0 ..> n) But probably adding a +1 at the end is good enough too for D. Better keep things simpler. Later, bearophile
Apr 21 2009
Reply to bearophile,Few things I have collected in the last days. What is the advantage of having a separate /+ +/ nestable comment syntax? Can't the /+ +/ be removed to make the normal /* */ syntax nestable? (IS the different C semantics of /* */ a problem here? I don't think so.)you spotted the issue, code porting and principle of least surprise
Apr 21 2009
BCS:you spotted the issue, code porting and principle of least surprise<- Code porting: If you port C code to D, it uses /* */ in a non nested way, so making /* */ nestable in D doesn't cause problems. The new semantic is backward compatible. - The principle of least surprise: a C programmer doesn't nest them. So if used correctly there's no surprise. If he/she/shi tries to nest them (creating a bug if it's C code) finds their increased semantic meaning. I don't think this can lead to bugs. The new nesting semantic is natural, and quick to learn once you read about it, see it, or try it once. My editor colorizes the code correctly according to the nestable /+ +/ too. - Complexity: every syntactic bit removed from the D language is a gain. Less things to learn, to read about, to remember, etc. So I'm for the removal of /+ +/ and making /* */ nestable. Bye, bearophile
Apr 21 2009
bearophile wrote:BCS:No. This is valid C: /* comment /* more comment */you spotted the issue, code porting and principle of least surprise<- Code porting: If you port C code to D, it uses /* */ in a non nested way- The principle of least surprise: a C programmer doesn't nest them.Nesting occurs often when various portions of code are commented.- Complexity: every syntactic bit removed from the D language is a gain.I guess I agree with this.So I'm for the removal of /+ +/ and making /* */ nestable.This can't work. Andrei
Apr 21 2009
"Andrei Alexandrescu" <SeeWebsiteForEmail erdani.org> wrote in message news:gsku34$29tn$1 digitalmars.com...bearophile wrote:That seems like a rather trivial thing to be designing our language around. And regarding principle of least surprise, the current /**/ behavior is only least-surprise for people who are already familiar with that particular detail of /**/. From a fresher perspective, the /++/ behavior is vastly less surprising. I can understand the desire not to cause too much trouble for porting, but sometimes I think D places far too much emphasis on that.BCS:No. This is valid C: /* comment /* more comment */you spotted the issue, code porting and principle of least surprise<- Code porting: If you port C code to D, it uses /* */ in a non nested way
Apr 21 2009
Reply to Nick,"Andrei Alexandrescu" <SeeWebsiteForEmail erdani.org> wrote in message news:gsku34$29tn$1 digitalmars.com...I'd be fine depricating /**/.bearophile wrote:That seems like a rather trivial thing to be designing our language around. And regarding principle of least surprise, the current /**/ behavior is only least-surprise for people who are already familiar with that particular detail of /**/. From a fresher perspective, the /++/ behavior is vastly less surprising. I can understand the desire not to cause too much trouble for porting, but sometimes I think D places far too much emphasis on that.BCS:No. This is valid C: /* comment /* more comment */you spotted the issue, code porting and principle of least surprise<- Code porting: If you port C code to D, it uses /* */ in a non nested way
Apr 21 2009
On Tue, 21 Apr 2009 23:42:20 +0400, BCS <ao pathlink.com> wrote:Reply to Nick,You mean, deprecating /++/? Personally, I rarely use /++/ because it feels uncommon and unstandard. I will be glad if /**/ become nestable and /++/ go away."Andrei Alexandrescu" <SeeWebsiteForEmail erdani.org> wrote in message news:gsku34$29tn$1 digitalmars.com...I'd be fine depricating /**/.bearophile wrote:That seems like a rather trivial thing to be designing our language around. And regarding principle of least surprise, the current /**/ behavior is only least-surprise for people who are already familiar with that particular detail of /**/. From a fresher perspective, the /++/ behavior is vastly less surprising. I can understand the desire not to cause too much trouble for porting, but sometimes I think D places far too much emphasis on that.BCS:No. This is valid C: /* comment /* more comment */you spotted the issue, code porting and principle of least surprise<- Code porting: If you port C code to D, it uses /* */ in a non nested way
Apr 21 2009
Reply to Denis,No, I mean exactly what I said. /**/ has well defined semantics, changing it will cause problems that replacing it will not.I'd be fine depricating /**/.You mean, deprecating /++/?
Apr 21 2009
Reply to Benjamin,Reply to Denis,I'd also be fine with doing nothing. What I'd not be fine with is making /**/ nest.No, I mean exactly what I said. /**/ has well defined semantics, changing it will cause problems that replacing it will not.I'd be fine depricating /**/.You mean, deprecating /++/?
Apr 21 2009
"BCS" <ao pathlink.com> wrote in message news:78ccfa2d3e7918cb909fe7a39778 news.digitalmars.com...Reply to Denis,Are there any problems you see with it other than porting code to D? (FWIW, I've never come across any code that had a /* in between a /* and */.)No, I mean exactly what I said. /**/ has well defined semantics, changing it will cause problems that replacing it will not.I'd be fine depricating /**/.You mean, deprecating /++/?
Apr 21 2009
Nick Sabalausky Wrote:"BCS" <ao pathlink.com> wrote in message news:78ccfa2d3e7918cb909fe7a39778 news.digitalmars.com...I've seen lots of code that did that. Now, if you mean code that intentionally did that... PaulReply to Denis,Are there any problems you see with it other than porting code to D? (FWIW, I've never come across any code that had a /* in between a /* and */.)No, I mean exactly what I said. /**/ has well defined semantics, changing it will cause problems that replacing it will not.I'd be fine depricating /**/.You mean, deprecating /++/?
Apr 21 2009
On Tue, Apr 21, 2009 at 2:24 PM, Paul D. Anderson <paul.d.removethis.anderson comcast.andthis.net> wrote:Nick Sabalausky Wrote:I could see (and maybe have seen?) people using it in comments: /******/ /* big /* long /* comment /* box /*******/ --bb"BCS" <ao pathlink.com> wrote in message news:78ccfa2d3e7918cb909fe7a39778 news.digitalmars.com...I've seen lots of code that did that. Now, if you mean code that intentionally did that...Reply to Denis,Are there any problems you see with it other than porting code to D? (FWIW, I've never come across any code that had a /* in between a /* and */.)No, I mean exactly what I said. /**/ has well defined semantics, changing it will cause problems that replacing it will not.I'd be fine depricating /**/.You mean, deprecating /++/?
Apr 21 2009
"Bill Baxter" <wbaxter gmail.com> wrote in message news:mailman.1179.1240349493.22690.digitalmars-d puremagic.com...On Tue, Apr 21, 2009 at 2:24 PM, Paul D. Anderson <paul.d.removethis.anderson comcast.andthis.net> wrote:Yea, but something like that would be trivial to notice and fix. And come to think of it, even if it was commented-code instead of a doc block: regular code /* commented code /* more commented code */ regular code that becomes accidentially commented That would still be easily detectable because, assuming the original code was compiling in the original language (which would almost certainly be the case if you're actually bothering to port it), then there wouldn't be enough matching '*/'s and the rest of the file would be commented out. And that's something that I really can't imagine would ever cause a successfully-compiling logic error. What you'd get, if not a "block comment never closed" error, would be an error from a {}, (), or [] never being closed, or a symbol not defined error. If none of those errors occurr, then whatever had been accidentially-commented would have already been dead code to begin with.Nick Sabalausky Wrote:I could see (and maybe have seen?) people using it in comments: /******/ /* big /* long /* comment /* box /*******/ --bb"BCS" <ao pathlink.com> wrote in message news:78ccfa2d3e7918cb909fe7a39778 news.digitalmars.com...I've seen lots of code that did that. Now, if you mean code that intentionally did that...Reply to Denis,Are there any problems you see with it other than porting code to D? (FWIW, I've never come across any code that had a /* in between a /* and */.)No, I mean exactly what I said. /**/ has well defined semantics, changing it will cause problems that replacing it will not.I'd be fine depricating /**/.You mean, deprecating /++/?
Apr 21 2009
On Tue, Apr 21, 2009 at 3:50 PM, Nick Sabalausky <a a.a> wrote:"Bill Baxter" <wbaxter gmail.com> wrote in message news:mailman.1179.1240349493.22690.digitalmars-d puremagic.com...tOn Tue, Apr 21, 2009 at 2:24 PM, Paul D. Anderson <paul.d.removethis.anderson comcast.andthis.net> wrote:Nick Sabalausky Wrote:"BCS" <ao pathlink.com> wrote in message news:78ccfa2d3e7918cb909fe7a39778 news.digitalmars.com...Reply to Denis,No, I mean exactly what I said. /**/ has well defined semantics, changing it will cause problems tha=I'd be fine depricating /**/.You mean, deprecating /++/?heYea, but something like that would be trivial to notice and fix. And come to think of it, even if it was commented-code instead of a doc block: regular code /* commented code /* more commented code */ regular code that becomes accidentially commented That would still be easily detectable because, assuming the original code was compiling in the original language (which would almost certainly be t=I could see (and maybe have seen?) people using it in comments: /******/ /* =A0big /* =A0long /* =A0comment /* =A0box /*******/ --bbI've seen lots of code that did that. Now, if you mean code that intentionally did that...replacing it will not.Are there any problems you see with it other than porting code to D? (FWIW, I've never come across any code that had a /* in between a /* and */.)case if you're actually bothering to port it), then there wouldn't be eno=ughmatching '*/'s and the rest of the file would be commented out. And that'=ssomething that I really can't imagine would ever cause a successfully-compiling logic error. What you'd get, if not a "block comme=ntnever closed" error, would be an error from a {}, (), or [] never being closed, or a symbol not defined error. If none of those errors occurr, th=enwhatever had been accidentially-commented would have already been dead co=deto begin with.I agree that if Walter had chosen to just make /* */ nestable originally it would have been a fine choice. But now that D has had /+ +/ for ten years or so, I don't see much point in changing it. It will only break everyone's code for what is a miniscule benefit at best, and a miniscule detriment at worst, depending on who you ask. --bb
Apr 21 2009
On Tue, 21 Apr 2009 16:18:34 -0700, Bill Baxter wrote:I agree that if Walter had chosen to just make /* */ nestable originally it would have been a fine choice. But now that D has had /+ +/ for ten years or so, I don't see much point in changing it. It will only break everyone's code for what is a miniscule benefit at best, and a miniscule detriment at worst, depending on who you ask.Yes, this is the legacy we now must keep. -- Derek Parnell Melbourne, Australia skype: derek.j.parnell
Apr 21 2009
Derek Parnell:Yes, this is the legacy we now must keep.I am willing to modify the D2 code written by everyone before April 22 2009 to remove the /+ +/ and replace it with the /* */, once the latter are nestable :-) (Mostly it's Phobos2, I presume). Bye, bearophile
Apr 22 2009
On Tue, 21 Apr 2009 20:55:03 +0000 (UTC), BCS wrote:/**/ has well defined semantics,... in the C programming language ...changing it will cause problems that replacing it will not.The "well defined semantics" are not god-given axioms, or to rephrase it, because something is 'thus' in C does not mean that it must also be 'thus' in any other programming language. For something to be in a programming language, it needs to be justified on its own terms rather than only using precedent as its rationale to exist. -- Derek Parnell Melbourne, Australia skype: derek.j.parnell
Apr 21 2009
"Derek Parnell" <derek psych.ward> wrote in message news:hn975kl8v6wa.bjme1g5z2jj3$.dlg 40tude.net...On Tue, 21 Apr 2009 20:55:03 +0000 (UTC), BCS wrote:I agree with you on this, however I think what they meant was that (unless I'm mistaken) /**/ also behaves the same way in every other language that actually uses /**/ for comments./**/ has well defined semantics,... in the C programming language ...changing it will cause problems that replacing it will not.The "well defined semantics" are not god-given axioms, or to rephrase it, because something is 'thus' in C does not mean that it must also be 'thus' in any other programming language. For something to be in a programming language, it needs to be justified on its own terms rather than only using precedent as its rationale to exist.
Apr 21 2009
On Tue, 21 Apr 2009 18:52:48 -0400, Nick Sabalausky wrote:I think what they meant was that (unless I'm mistaken) /**/ also behaves the same way in every other language that actually uses /**/ for comments.However, I regularly use the Progress language in which /* */ are nestable. I know that it is a rather obscure language but it does indicate that /* */ can be nested successfully. -- Derek Parnell Melbourne, Australia skype: derek.j.parnell
Apr 21 2009
Hello Nick,"Derek Parnell" <derek psych.ward> wrote in message news:hn975kl8v6wa.bjme1g5z2jj3$.dlg 40tude.net...Yes, exactly my point.On Tue, 21 Apr 2009 20:55:03 +0000 (UTC), BCS wrote:/**/ has well defined semantics,... in the C programming language ...Precedent is a good reason to exist in /some given form/ if it is to exist at all.changing it will cause problems that replacing it will not.The "well defined semantics" are not god-given axioms, or to rephrase it, because something is 'thus' in C does not mean that it must also be 'thus' in any other programming language. For something to be in a programming language, it needs to be justified on its own terms rather than only using precedent as its rationale to exist.I agree with you on this, however I think what they meant was that (unless I'm mistaken) /**/ also behaves the same way in every other language that actually uses /**/ for comments.So, ditto Nick on that one.
Apr 22 2009
On Tue, 21 Apr 2009 13:45:44 -0400, Nick Sabalausky wrote:I can understand the desire not to cause too much trouble for porting, but sometimes I think D places far too much emphasis on that."sometimes" !? -- Derek Parnell Melbourne, Australia skype: derek.j.parnell
Apr 21 2009
"Derek Parnell" <derek psych.ward> wrote in message news:1w5qr20r0ro12.n5x2lan1yen4.dlg 40tude.net...On Tue, 21 Apr 2009 13:45:44 -0400, Nick Sabalausky wrote:Well, I'm not always thinking about D! Sometimes I'm thinking about Stargate ;)I can understand the desire not to cause too much trouble for porting, but sometimes I think D places far too much emphasis on that."sometimes" !?
Apr 21 2009
bearophile wrote:What is the advantage of having a separate /+ +/ nestable comment syntax? Can't the /+ +/ be removed to make the normal /* */ syntax nestable? (IS the different C semantics of /* */ a problem here? I don't think so.)Sometimes it's handy to have non-nesting comments. For example, when debugging something, I sometimes use: --- foo(); /* bar(); /* baz(); //*/ --- So I can quickly remove the first '/*' (by prepending '/') to uncomment bar() but not baz(). Also, Walter may feel differently about the C-compatibility thing than you do :).The std.intrinsic module may gain a standard way to perform a 64-bit by 32-bit division, for the situations where you know the quotient will fit in 32 bits ('divl' instruction on X86). CPUs that don't support such operation can use the normal 64-big division.That just sounds like a possible compiler optimization for --- ulong L; uint I; // initialize L & I auto result = cast(uint)(L / I); ---
Apr 22 2009