D - Identity & equivalence
- Matthew Wilson (3/3) Mar 25 2003 If I remember, last year there was debate on using == and === operators ...
- Jon Allen (2/5) Mar 25 2003 === is identity, while == is equivalence
- xyzzy (6/18) Mar 25 2003 Why? I can see LOTS of people forgetting which is which unless there is ...
- Jon Allen (4/25) Mar 25 2003 == is already equivalence in C and D is based on C. It kind of follows
- Matthew Wilson (4/29) Mar 25 2003 The reasoning is sound. I'm glad it's not changed from the position last
- Farmer (20/56) Mar 26 2003 Just a few thousands C, C++, Java and C# programmers will experience qui...
- Matthew Wilson (9/64) Mar 26 2003 No, say it ain't so!
- Ilya Minkov (35/48) Mar 28 2003 Wouldn't you normally write ?:
- Matthew Wilson (27/78) Mar 29 2003 I think most of your points have been ably addressed in the other thread...
- Luna Kid (1/1) Mar 29 2003 (I'm starting another thread on this. Sab)
- Sean L. Palmer (13/99) Mar 29 2003 Jump off a cliff. I like terse syntax.
- Andy Friesen (7/20) Mar 29 2003 Object o = ...;
- Luna Kid (24/43) Mar 29 2003 perhaps).
- Matthew Wilson (18/137) Mar 29 2003 How impolite
- Sean L. Palmer (19/164) Mar 30 2003 He called my proposition ludicrous! ;)
- Matthew Wilson (16/183) Mar 30 2003 Quit & peace, my brother. :)
- Matthew Wilson (13/200) Mar 30 2003 Sorry, that should have read "Quits", as in we're quits, as in let's dro...
- Sean L. Palmer (8/12) Mar 30 2003 I grok.
- Matthew Wilson (7/20) Mar 30 2003 My plan is to work on all the intransigent opposing advocates, and once ...
- Sean L. Palmer (7/13) Mar 30 2003 It's all in good fun.
-
Farmer
(43/50)
Mar 30 2003
"Matthew Wilson"
wrote in - Matthew Wilson (6/55) May 21 2003 I've saved this one as unread, and come back to it this morning. Nasty
- Walter (3/7) May 24 2003 There are some good ideas there.
- Matthew Wilson (4/12) Jul 09 2003 Any responses on this one yet?
- Walter (3/4) Jul 10 2003 Not yet!
- Antti Sykari (21/37) Mar 29 2003 Certainly the if () construct must only have boolean bit values. All
- Luna Kid (29/41) Mar 29 2003 Some of it *is* practical. All of it, unleashed, leads
- Farmer (12/30) Mar 30 2003 I don't buy that. I prefer to stick to the truth.
- Matthew Wilson (5/15) Mar 25 2003 Cheers, mate. :)
If I remember, last year there was debate on using == and === operators for representing equivalence and identity. Is this correct? Still the case? If so, which one is which?
Mar 25 2003
In article <b5r826$2pjt$1 digitaldaemon.com>, Matthew Wilson says...If I remember, last year there was debate on using == and === operators for representing equivalence and identity. Is this correct? Still the case? If so, which one is which?=== is identity, while == is equivalence
Mar 25 2003
On Wed, 26 Mar 2003 04:05:35 +0000 (UTC), Jon Allen <jallen minotstateu.edu> wrote:In article <b5r826$2pjt$1 digitaldaemon.com>, Matthew Wilson says...Why? I can see LOTS of people forgetting which is which unless there is a good rationale for the current position. -- xyzzyIf I remember, last year there was debate on using == and === operators for representing equivalence and identity. Is this correct? Still the case? If so, which one is which?=== is identity, while == is equivalence
Mar 25 2003
xyzzy wrote:On Wed, 26 Mar 2003 04:05:35 +0000 (UTC), Jon Allen <jallen minotstateu.edu> wrote:== is already equivalence in C and D is based on C. It kind of follows that === is more equal, or the identity. At least that's how I think of it. I don't know if it's a _good_ reason, but it works for me.In article <b5r826$2pjt$1 digitaldaemon.com>, Matthew Wilson says...Why? I can see LOTS of people forgetting which is which unless there is a good rationale for the current position.If I remember, last year there was debate on using == and === operators for representing equivalence and identity. Is this correct? Still the case? If so, which one is which?=== is identity, while == is equivalence
Mar 25 2003
The reasoning is sound. I'm glad it's not changed from the position last year, as I think it's at the zenith of sense. "Jon Allen" <jallen minotstateu.edu> wrote in message news:b5ranu$2rnb$1 digitaldaemon.com...xyzzy wrote:On Wed, 26 Mar 2003 04:05:35 +0000 (UTC), Jon Allen <jallen minotstateu.edu> wrote:== is already equivalence in C and D is based on C. It kind of follows that === is more equal, or the identity. At least that's how I think of it. I don't know if it's a _good_ reason, but it works for me.In article <b5r826$2pjt$1 digitaldaemon.com>, Matthew Wilson says...Why? I can see LOTS of people forgetting which is which unless there is a good rationale for the current position.If I remember, last year there was debate on using == and === operators for representing equivalence and identity. Is this correct? Still the case? If so, which one is which?=== is identity, while == is equivalence
Mar 25 2003
"Matthew Wilson" <dmd synesis.com.au> wrote in news:b5rf0o$2unl$1 digitaldaemon.com:The reasoning is sound. I'm glad it's not changed from the position last year, as I think it's at the zenith of sense.a suprise when their newly written D code crashes ! SomeClass obj; if (obj != null) // access violation when obj===null { // do sth. with obj } if (obj == null) // access violation when obj===null { obj=new SomeClass(); // init now } The D compiler issues no warning for possible use of uninitialized reference to 'obj'. Furthermore there aren't any automatic nullpointer checks in D. Too bad, that the (incorrect) explicit nullpointer checks won't help, either. When programming in D, better get your debugger started ;-) Farmer."Jon Allen" <jallen minotstateu.edu> wrote in message news:b5ranu$2rnb$1 digitaldaemon.com...xyzzy wrote:On Wed, 26 Mar 2003 04:05:35 +0000 (UTC), Jon Allen <jallen minotstateu.edu> wrote:== is already equivalence in C and D is based on C. It kind of follows that === is more equal, or the identity. At least that's how I think of it. I don't know if it's a _good_ reason, but it works for me.In article <b5r826$2pjt$1 digitaldaemon.com>, Matthew Wilson says...Why? I can see LOTS of people forgetting which is which unless there is a good rationale for the current position.If I remember, last year there was debate on using == and === operators for representing equivalence and identity. Is this correct? Still the case? If so, which one is which?=== is identity, while == is equivalence
Mar 26 2003
No, say it ain't so! I guess this touches on my other thread "null == o?", on which I've only just read the single response. This all sucks enormously! I kind of understand the efficiency reason for == not checking for null before conducting its comparisons, but it's nowhere near a sufficient reason. [I'm taking this onto the other thread.] "Farmer" <itsFarmer. freenet.de> wrote in message news:Xns934B783EDAFEitsFarmer 63.105.9.61..."Matthew Wilson" <dmd synesis.com.au> wrote in news:b5rf0o$2unl$1 digitaldaemon.com:The reasoning is sound. I'm glad it's not changed from the position last year, as I think it's at the zenith of sense.a suprise when their newly written D code crashes ! SomeClass obj; if (obj != null) // access violation when obj===null { // do sth. with obj } if (obj == null) // access violation when obj===null { obj=new SomeClass(); // init now } The D compiler issues no warning for possible use of uninitialized reference to 'obj'. Furthermore there aren't any automatic nullpointer checks in D. Too bad, that the (incorrect) explicit nullpointer checks won't help, either. When programming in D, better get your debugger started ;-) Farmer."Jon Allen" <jallen minotstateu.edu> wrote in message news:b5ranu$2rnb$1 digitaldaemon.com...xyzzy wrote:On Wed, 26 Mar 2003 04:05:35 +0000 (UTC), Jon Allen <jallen minotstateu.edu> wrote:== is already equivalence in C and D is based on C. It kind of follows that === is more equal, or the identity. At least that's how I think of it. I don't know if it's a _good_ reason, but it works for me.In article <b5r826$2pjt$1 digitaldaemon.com>, Matthew Wilson says...Why? I can see LOTS of people forgetting which is which unless there is a good rationale for the current position.If I remember, last year there was debate on using == and === operators for representing equivalence and identity. Is this correct? Still the case? If so, which one is which?=== is identity, while == is equivalence
Mar 26 2003
Farmer wrote:a suprise when their newly written D code crashes ! SomeClass obj; if (obj != null) // access violation when obj===null { // do sth. with obj } if (obj == null) // access violation when obj===null { obj=new SomeClass(); // init now }Wouldn't you normally write ?: if (obj) {} if (!obj) {} This looks much more meaningful anyway. You test an object for existance, that is "to be or not to be". :) Basically, you don't need to be able to compare an object with NULL (Warning!), but it may be requiered to be able to compare 2 objects by reference. However, it is much more intuitive to compare by contents. You write a==b to compare integers by contents, not by reference. So why should you make it all inconsistent and compare other things by reference? Forget of objects being pointers. They are objects. Simply that. And understand that carrying around dead objects (yes, that's what they are - the NULL ponters) is harmful anyway and requieres questioning your concept. Read the Daniel's comment on the "null == o?" thread. BTW, with good exception handling, like the one D promises, NULL pointer dereferencing is not yet program's death. And you don't have to consider it in every line of a program. Your functions don't even have to yuild a dead object in first place - why don't you just raise your own exception and catch it on the upper level without cluttering your code with pointer checks? Dead object usually *is* an error indicator. An object which has been destroyed and then reused or simply stored away? Remember RAII. And aren't exceptions better because they almost don't slow down the normal case code? I think the c++ decision came from underlying implementation. And if you look at lots of code, it often uses pointer equality for comparisons, and thus under no circumstances copies objects unless they change. This may be somewhat error-prone and restricts the use of functional concepts in everyday programming. As to efficiency, you would first want a running program, and then you could see where efficiency suffers and fix it. At this later stage, D imposes no restriction on it. You can guess nowever you like, but one never knows what makes the program slow before some actual profiling. -i.
Mar 28 2003
I think most of your points have been ably addressed in the other thread, by myself and several others. I'd like to comment onWouldn't you normally write ?: if (obj) {} if (!obj) {}better than C and C++ (and, I think, D). The expressions in conditionals should be explicitly boolean. Hence int i = 1; X x = new X(); if(i) { if(!x) { Neither of those are sensible syntax. They are pandering to the ludicrous proposition that the extra typing to get to if(i != 0) { if(x == null) { isn't infinitesimally insignificant when compared to the codification of the rest of the source, not to mention the costs in terms of extra maintenance by doing such things. If there's one criticism I'd make of the thrust of lots of arguments in this newsgroup, it is the focus on the convenience of code authors without much thought for code maintainers (even where coder === the maintainer) "Ilya Minkov" <midiclub tiscali.de> wrote in message news:b61ii2$mft$1 digitaldaemon.com...Farmer wrote:quitea suprise when their newly written D code crashes ! SomeClass obj; if (obj != null) // access violation when obj===null { // do sth. with obj } if (obj == null) // access violation when obj===null { obj=new SomeClass(); // init now }Wouldn't you normally write ?: if (obj) {} if (!obj) {} This looks much more meaningful anyway. You test an object for existance, that is "to be or not to be". :) Basically, you don't need to be able to compare an object with NULL (Warning!), but it may be requiered to be able to compare 2 objects by reference. However, it is much more intuitive to compare by contents. You write a==b to compare integers by contents, not by reference. So why should you make it all inconsistent and compare other things by reference? Forget of objects being pointers. They are objects. Simply that. And understand that carrying around dead objects (yes, that's what they are - the NULL ponters) is harmful anyway and requieres questioning your concept. Read the Daniel's comment on the "null == o?" thread. BTW, with good exception handling, like the one D promises, NULL pointer dereferencing is not yet program's death. And you don't have to consider it in every line of a program. Your functions don't even have to yuild a dead object in first place - why don't you just raise your own exception and catch it on the upper level without cluttering your code with pointer checks? Dead object usually *is* an error indicator. An object which has been destroyed and then reused or simply stored away? Remember RAII. And aren't exceptions better because they almost don't slow down the normal case code? I think the c++ decision came from underlying implementation. And if you look at lots of code, it often uses pointer equality for comparisons, and thus under no circumstances copies objects unless they change. This may be somewhat error-prone and restricts the use of functional concepts in everyday programming. As to efficiency, you would first want a running program, and then you could see where efficiency suffers and fix it. At this later stage, D imposes no restriction on it. You can guess nowever you like, but one never knows what makes the program slow before some actual profiling. -i.
Mar 29 2003
Jump off a cliff. I like terse syntax. if(i) {} if(!x) {} Both ok in my book. Everybody knows what they mean (except you, perhaps). Why should the only thing that produces a bool be a comparison? Why should there not be operators especially for comparison against null and zero? Those *are* the most common cases. Sean "Matthew Wilson" <dmd synesis.com.au> wrote in message news:b64c71$2rgd$1 digitaldaemon.com...I think most of your points have been ably addressed in the other thread,bymyself and several others. I'd like to comment ontheWouldn't you normally write ?: if (obj) {} if (!obj) {}better than C and C++ (and, I think, D). The expressions in conditionals should be explicitly boolean. Hence int i = 1; X x = new X(); if(i) { if(!x) { Neither of those are sensible syntax. They are pandering to the ludicrous proposition that the extra typing to get to if(i != 0) { if(x == null) { isn't infinitesimally insignificant when compared to the codification ofrest of the source, not to mention the costs in terms of extra maintenance by doing such things. If there's one criticism I'd make of the thrust of lots of arguments inthisnewsgroup, it is the focus on the convenience of code authors without much thought for code maintainers (even where coder === the maintainer) "Ilya Minkov" <midiclub tiscali.de> wrote in message news:b61ii2$mft$1 digitaldaemon.com...Farmer wrote:quitea suprise when their newly written D code crashes ! SomeClass obj; if (obj != null) // access violation when obj===null { // do sth. with obj } if (obj == null) // access violation when obj===null { obj=new SomeClass(); // init now }Wouldn't you normally write ?: if (obj) {} if (!obj) {} This looks much more meaningful anyway. You test an object for existance, that is "to be or not to be". :) Basically, you don't need to be able to compare an object with NULL (Warning!), but it may be requiered to be able to compare 2 objects by reference. However, it is much more intuitive to compare by contents. You write a==b to compare integers by contents, not by reference. So why should you make it all inconsistent and compare other things by reference? Forget of objects being pointers. They are objects. Simply that. And understand that carrying around dead objects (yes, that's what they are - the NULL ponters) is harmful anyway and requieres questioning your concept. Read the Daniel's comment on the "null == o?" thread. BTW, with good exception handling, like the one D promises, NULL pointer dereferencing is not yet program's death. And you don't have to consider it in every line of a program. Your functions don't even have to yuild a dead object in first place - why don't you just raise your own exception and catch it on the upper level without cluttering your code with pointer checks? Dead object usually *is* an error indicator. An object which has been destroyed and then reused or simply stored away? Remember RAII. And aren't exceptions better because they almost don't slow down the normal case code? I think the c++ decision came from underlying implementation. And if you look at lots of code, it often uses pointer equality for comparisons, and thus under no circumstances copies objects unless they change. This may be somewhat error-prone and restricts the use of functional concepts in everyday programming. As to efficiency, you would first want a running program, and then you could see where efficiency suffers and fix it. At this later stage, D imposes no restriction on it. You can guess nowever you like, but one never knows what makes the program slow before some actual profiling. -i.
Mar 29 2003
Sean L. Palmer wrote:Jump off a cliff. I like terse syntax. if(i) {} if(!x) {} Both ok in my book. Everybody knows what they mean (except you, perhaps). Why should the only thing that produces a bool be a comparison? Why should there not be operators especially for comparison against null and zero? Those *are* the most common cases. SeanObject o = ...; bit b = o; // O_O if (o == b) ...; // _ In any other context, it makes absolutely no sense. if (o !== null) doesn't strike me as being hyperverbose or tedious. -- andy
Mar 29 2003
"Andy Friesen" <andy ikagames.com> wrote in message news:b64v57$6sd$1 digitaldaemon.com...Sean L. Palmer wrote:perhaps).Jump off a cliff. I like terse syntax. if(i) {} if(!x) {} Both ok in my book. Everybody knows what they mean (except you,andWhy should the only thing that produces a bool be a comparison? Why should there not be operators especially for comparison against nullLet's bring this if(x) topic to the new thread I started for it: 'On "if (x)" and initialization...'. The reason people have endless debates on this issue is because no language properly support the abstraction expressed by if(x), so some see it as "real if with bool", and others see it "checking for usable object". Both are perfectly valid and common uses, but they are different things, expressed with the same syntax. That reads: poor language design. As Sean said: "Why should there not be operators especially for comparison against null and zero? Those *are* the most common cases." Absolutely on the point. That if (x) is a hack that most practical languages *encourage* to use, because they knowingly acknowledge its parctical value, but still not developed enough to have explicit syntactic (and semantic) facilities for supporting the deeper meaning of that statement. Luna Kidzero? Those *are* the most common cases. SeanObject o = ...; bit b = o; // O_O if (o == b) ...; // _ In any other context, it makes absolutely no sense. if (o !== null) doesn't strike me as being hyperverbose or tedious.
Mar 29 2003
How impolite "Sean L. Palmer" <seanpalmer directvinternet.com> wrote in message news:b64t3q$5l4$1 digitaldaemon.com...Jump off a cliff. I like terse syntax. if(i) {} if(!x) {} Both ok in my book. Everybody knows what they mean (except you, perhaps). Why should the only thing that produces a bool be a comparison? Why should there not be operators especially for comparison against nullandzero? Those *are* the most common cases. Sean "Matthew Wilson" <dmd synesis.com.au> wrote in message news:b64c71$2rgd$1 digitaldaemon.com...thread,I think most of your points have been ably addressed in the otherbyfarmyself and several others. I'd like to comment onWouldn't you normally write ?: if (obj) {} if (!obj) {}ludicrousbetter than C and C++ (and, I think, D). The expressions in conditionals should be explicitly boolean. Hence int i = 1; X x = new X(); if(i) { if(!x) { Neither of those are sensible syntax. They are pandering to themaintenanceproposition that the extra typing to get to if(i != 0) { if(x == null) { isn't infinitesimally insignificant when compared to the codification oftherest of the source, not to mention the costs in terms of extramuchby doing such things. If there's one criticism I'd make of the thrust of lots of arguments inthisnewsgroup, it is the focus on the convenience of code authors withoutarethought for code maintainers (even where coder === the maintainer) "Ilya Minkov" <midiclub tiscali.de> wrote in message news:b61ii2$mft$1 digitaldaemon.com...Farmer wrote:quitea suprise when their newly written D code crashes ! SomeClass obj; if (obj != null) // access violation when obj===null { // do sth. with obj } if (obj == null) // access violation when obj===null { obj=new SomeClass(); // init now }Wouldn't you normally write ?: if (obj) {} if (!obj) {} This looks much more meaningful anyway. You test an object for existance, that is "to be or not to be". :) Basically, you don't need to be able to compare an object with NULL (Warning!), but it may be requiered to be able to compare 2 objects by reference. However, it is much more intuitive to compare by contents. You write a==b to compare integers by contents, not by reference. So why should you make it all inconsistent and compare other things by reference? Forget of objects being pointers. They are objects. Simply that. And understand that carrying around dead objects (yes, that's what theypointer- the NULL ponters) is harmful anyway and requieres questioning your concept. Read the Daniel's comment on the "null == o?" thread. BTW, with good exception handling, like the one D promises, NULLconsiderdereferencing is not yet program's death. And you don't have toait in every line of a program. Your functions don't even have to yuildexceptiondead object in first place - why don't you just raise your ownRememberand catch it on the upper level without cluttering your code with pointer checks? Dead object usually *is* an error indicator. An object which has been destroyed and then reused or simply stored away?youRAII. And aren't exceptions better because they almost don't slow down the normal case code? I think the c++ decision came from underlying implementation. And ifThislook at lots of code, it often uses pointer equality for comparisons, and thus under no circumstances copies objects unless they change.conceptsmay be somewhat error-prone and restricts the use of functionalin everyday programming. As to efficiency, you would first want a running program, and then you could see where efficiency suffers and fix it. At this later stage, D imposes no restriction on it. You can guess nowever you like, but one never knows what makes the program slow before some actual profiling. -i.
Mar 29 2003
He called my proposition ludicrous! ;) Sean "Matthew Wilson" <dmd synesis.com.au> wrote in message news:b65aqc$f0n$1 digitaldaemon.com...How impolite "Sean L. Palmer" <seanpalmer directvinternet.com> wrote in message news:b64t3q$5l4$1 digitaldaemon.com...perhaps).Jump off a cliff. I like terse syntax. if(i) {} if(!x) {} Both ok in my book. Everybody knows what they mean (except you,conditionalsWhy should the only thing that produces a bool be a comparison? Why should there not be operators especially for comparison against nullandzero? Those *are* the most common cases. Sean "Matthew Wilson" <dmd synesis.com.au> wrote in message news:b64c71$2rgd$1 digitaldaemon.com...thread,I think most of your points have been ably addressed in the otherbyfarmyself and several others. I'd like to comment onWouldn't you normally write ?: if (obj) {} if (!obj) {}better than C and C++ (and, I think, D). The expressions inofludicrousshould be explicitly boolean. Hence int i = 1; X x = new X(); if(i) { if(!x) { Neither of those are sensible syntax. They are pandering to theproposition that the extra typing to get to if(i != 0) { if(x == null) { isn't infinitesimally insignificant when compared to the codificationinthemaintenancerest of the source, not to mention the costs in terms of extraby doing such things. If there's one criticism I'd make of the thrust of lots of argumentsexperiencethismuchnewsgroup, it is the focus on the convenience of code authors withoutthought for code maintainers (even where coder === the maintainer) "Ilya Minkov" <midiclub tiscali.de> wrote in message news:b61ii2$mft$1 digitaldaemon.com...Farmer wrote:byquitea suprise when their newly written D code crashes ! SomeClass obj; if (obj != null) // access violation when obj===null { // do sth. with obj } if (obj == null) // access violation when obj===null { obj=new SomeClass(); // init now }Wouldn't you normally write ?: if (obj) {} if (!obj) {} This looks much more meaningful anyway. You test an object for existance, that is "to be or not to be". :) Basically, you don't need to be able to compare an object with NULL (Warning!), but it may be requiered to be able to compare 2 objectsshouldreference. However, it is much more intuitive to compare by contents. You write a==b to compare integers by contents, not by reference. So whyyuildareyou make it all inconsistent and compare other things by reference? Forget of objects being pointers. They are objects. Simply that. And understand that carrying around dead objects (yes, that's what theypointer- the NULL ponters) is harmful anyway and requieres questioning your concept. Read the Daniel's comment on the "null == o?" thread. BTW, with good exception handling, like the one D promises, NULLconsiderdereferencing is not yet program's death. And you don't have toit in every line of a program. Your functions don't even have toaobjectexceptiondead object in first place - why don't you just raise your ownand catch it on the upper level without cluttering your code with pointer checks? Dead object usually *is* an error indicator. AndownRememberwhich has been destroyed and then reused or simply stored away?RAII. And aren't exceptions better because they almost don't slowcomparisons,youthe normal case code? I think the c++ decision came from underlying implementation. And iflook at lots of code, it often uses pointer equality foryouThisand thus under no circumstances copies objects unless they change.conceptsmay be somewhat error-prone and restricts the use of functionalin everyday programming. As to efficiency, you would first want a running program, and thenDcould see where efficiency suffers and fix it. At this later stage,oneimposes no restriction on it. You can guess nowever you like, butprofiling.never knows what makes the program slow before some actual-i.
Mar 30 2003
Quit & peace, my brother. :) "Sean L. Palmer" <seanpalmer directvinternet.com> wrote in message news:b67g10$1raq$1 digitaldaemon.com...He called my proposition ludicrous! ;) Sean "Matthew Wilson" <dmd synesis.com.au> wrote in message news:b65aqc$f0n$1 digitaldaemon.com...nullHow impolite "Sean L. Palmer" <seanpalmer directvinternet.com> wrote in message news:b64t3q$5l4$1 digitaldaemon.com...perhaps).Jump off a cliff. I like terse syntax. if(i) {} if(!x) {} Both ok in my book. Everybody knows what they mean (except you,Why should the only thing that produces a bool be a comparison? Why should there not be operators especially for comparison againstisandzero? Those *are* the most common cases. Sean "Matthew Wilson" <dmd synesis.com.au> wrote in message news:b64c71$2rgd$1 digitaldaemon.com...thread,I think most of your points have been ably addressed in the otherbymyself and several others. I'd like to comment onWouldn't you normally write ?: if (obj) {} if (!obj) {}codificationfarconditionalsbetter than C and C++ (and, I think, D). The expressions inludicrousshould be explicitly boolean. Hence int i = 1; X x = new X(); if(i) { if(!x) { Neither of those are sensible syntax. They are pandering to theproposition that the extra typing to get to if(i != 0) { if(x == null) { isn't infinitesimally insignificant when compared to theofwithoutinthemaintenancerest of the source, not to mention the costs in terms of extraby doing such things. If there's one criticism I'd make of the thrust of lots of argumentsthisnewsgroup, it is the focus on the convenience of code authorsNULLmuchexperiencethought for code maintainers (even where coder === the maintainer) "Ilya Minkov" <midiclub tiscali.de> wrote in message news:b61ii2$mft$1 digitaldaemon.com...Farmer wrote:quitea suprise when their newly written D code crashes ! SomeClass obj; if (obj != null) // access violation when obj===null { // do sth. with obj } if (obj == null) // access violation when obj===null { obj=new SomeClass(); // init now }Wouldn't you normally write ?: if (obj) {} if (!obj) {} This looks much more meaningful anyway. You test an object for existance, that is "to be or not to be". :) Basically, you don't need to be able to compare an object withobjects(Warning!), but it may be requiered to be able to compare 2bywritereference. However, it is much more intuitive to compare by contents. Youreference?shoulda==b to compare integers by contents, not by reference. So whyyou make it all inconsistent and compare other things byAndForget of objects being pointers. They are objects. Simply that.theyunderstand that carrying around dead objects (yes, that's whatyourare- the NULL ponters) is harmful anyway and requieres questioningifyuildpointerconcept. Read the Daniel's comment on the "null == o?" thread. BTW, with good exception handling, like the one D promises, NULLconsiderdereferencing is not yet program's death. And you don't have toit in every line of a program. Your functions don't even have toaobjectexceptiondead object in first place - why don't you just raise your ownand catch it on the upper level without cluttering your code with pointer checks? Dead object usually *is* an error indicator. AndownRememberwhich has been destroyed and then reused or simply stored away?RAII. And aren't exceptions better because they almost don't slowthe normal case code? I think the c++ decision came from underlying implementation. Andstage,youcomparisons,look at lots of code, it often uses pointer equality foryouThisand thus under no circumstances copies objects unless they change.conceptsmay be somewhat error-prone and restricts the use of functionalin everyday programming. As to efficiency, you would first want a running program, and thencould see where efficiency suffers and fix it. At this laterDoneimposes no restriction on it. You can guess nowever you like, butprofiling.never knows what makes the program slow before some actual-i.
Mar 30 2003
Sorry, that should have read "Quits", as in we're quits, as in let's drop it with pride preserved on both sides. I didn't mean "Quit", as in shut up naughty boy. :) "Matthew Wilson" <dmd synesis.com.au> wrote in message news:b67nih$211k$1 digitaldaemon.com...Quit & peace, my brother. :) "Sean L. Palmer" <seanpalmer directvinternet.com> wrote in message news:b67g10$1raq$1 digitaldaemon.com...argumentsHe called my proposition ludicrous! ;) Sean "Matthew Wilson" <dmd synesis.com.au> wrote in message news:b65aqc$f0n$1 digitaldaemon.com...nullHow impolite "Sean L. Palmer" <seanpalmer directvinternet.com> wrote in message news:b64t3q$5l4$1 digitaldaemon.com...perhaps).Jump off a cliff. I like terse syntax. if(i) {} if(!x) {} Both ok in my book. Everybody knows what they mean (except you,Why should the only thing that produces a bool be a comparison? Why should there not be operators especially for comparison againstisandzero? Those *are* the most common cases. Sean "Matthew Wilson" <dmd synesis.com.au> wrote in message news:b64c71$2rgd$1 digitaldaemon.com...thread,I think most of your points have been ably addressed in the otherbymyself and several others. I'd like to comment onWouldn't you normally write ?: if (obj) {} if (!obj) {}codificationfarconditionalsbetter than C and C++ (and, I think, D). The expressions inludicrousshould be explicitly boolean. Hence int i = 1; X x = new X(); if(i) { if(!x) { Neither of those are sensible syntax. They are pandering to theproposition that the extra typing to get to if(i != 0) { if(x == null) { isn't infinitesimally insignificant when compared to theofthemaintenancerest of the source, not to mention the costs in terms of extraby doing such things. If there's one criticism I'd make of the thrust of lots ofwithinwithoutthisnewsgroup, it is the focus on the convenience of code authorsNULLmuchexperiencethought for code maintainers (even where coder === the maintainer) "Ilya Minkov" <midiclub tiscali.de> wrote in message news:b61ii2$mft$1 digitaldaemon.com...Farmer wrote:quitea suprise when their newly written D code crashes ! SomeClass obj; if (obj != null) // access violation when obj===null { // do sth. with obj } if (obj == null) // access violation when obj===null { obj=new SomeClass(); // init now }Wouldn't you normally write ?: if (obj) {} if (!obj) {} This looks much more meaningful anyway. You test an object for existance, that is "to be or not to be". :) Basically, you don't need to be able to compare an object withobjects(Warning!), but it may be requiered to be able to compare 2bywritereference. However, it is much more intuitive to compare by contents. Youreference?shoulda==b to compare integers by contents, not by reference. So whyyou make it all inconsistent and compare other things byAndForget of objects being pointers. They are objects. Simply that.theyunderstand that carrying around dead objects (yes, that's whatyourare- the NULL ponters) is harmful anyway and requieres questioningyuildpointerconcept. Read the Daniel's comment on the "null == o?" thread. BTW, with good exception handling, like the one D promises, NULLconsiderdereferencing is not yet program's death. And you don't have toit in every line of a program. Your functions don't even have toaexceptiondead object in first place - why don't you just raise your ownand catch it on the upper level without cluttering your codeslowobjectpointer checks? Dead object usually *is* an error indicator. AnRememberwhich has been destroyed and then reused or simply stored away?RAII. And aren't exceptions better because they almost don'tAnddownthe normal case code? I think the c++ decision came from underlying implementation.ifchange.youcomparisons,look at lots of code, it often uses pointer equality forand thus under no circumstances copies objects unless theythenThisconceptsmay be somewhat error-prone and restricts the use of functionalin everyday programming. As to efficiency, you would first want a running program, andbutyoustage,could see where efficiency suffers and fix it. At this laterDimposes no restriction on it. You can guess nowever you like,oneprofiling.never knows what makes the program slow before some actual-i.
Mar 30 2003
I grok. I do think we should continue to debate this important issue, but without the evilness. ;) Unless the higher-ups deem it a hopeless religious war! Sean "Matthew Wilson" <dmd synesis.com.au> wrote in message news:b67ot3$21qk$1 digitaldaemon.com...Sorry, that should have read "Quits", as in we're quits, as in let's dropitwith pride preserved on both sides. I didn't mean "Quit", as in shut up naughty boy. :)
Mar 30 2003
My plan is to work on all the intransigent opposing advocates, and once a concerted POV is achieved to hit Walter with the newsgroup stick. (I must say, I'm not terribly confident of achieving even the first part of that, much less so the latter) "Sean L. Palmer" <palmer.sean verizon.net> wrote in message news:b67t5r$24q0$1 digitaldaemon.com...I grok. I do think we should continue to debate this important issue, but without the evilness. ;) Unless the higher-ups deem it a hopeless religious war! Sean "Matthew Wilson" <dmd synesis.com.au> wrote in message news:b67ot3$21qk$1 digitaldaemon.com...dropSorry, that should have read "Quits", as in we're quits, as in let'sitwith pride preserved on both sides. I didn't mean "Quit", as in shut up naughty boy. :)
Mar 30 2003
It's all in good fun. Mainly I reply here because I noticed I still had my old email address set for this server. In case anyone tried to email me directly please note the new addy. Sean "Matthew Wilson" <dmd synesis.com.au> wrote in message news:b67nih$211k$1 digitaldaemon.com...Quit & peace, my brother. :) "Sean L. Palmer" <seanpalmer directvinternet.com> wrote in message news:b67g10$1raq$1 digitaldaemon.com...He called my proposition ludicrous! ;) Sean
Mar 30 2003
"Matthew Wilson" <dmd synesis.com.au> wrote in news:b64c71$2rgd$1 digitaldaemon.com: [snip]If there's one criticism I'd make of the thrust of lots of arguments in this newsgroup, it is the focus on the convenience of code authors without much thought for code maintainers (even where coder === the maintainer)Here is some more stuff for upcoming D maintainerns to struggle with :-( int*[10] fooArray; fooArray[]=foo2; If you don't know foo2's type then you cannot guess what's happening: a) assuming int* foo2; fooArray is set to values of int* (like C memset). b) assuming int[9] foo2; The content of foo2 is copied to fooArray (like C memcopy). [Actually you get a runtime error "lengths don't match for array copy", for this example] By convention you could waste (read invest) 2 characters for writting fooArray[]=foo2[]; // xxx[]=xxx[] means "memcopy" whenever foo2 is an array in order to make things more obvious. int*[10] fooArray; foo3=fooArray; Again you don't know foo3's type. Then two very similar things could happen: a)assuming void* foo3; The address of fooArray's content is taken. [In case a) the writer might intended "foo3=fooArray[1];" instead of "foo3=fooArray;"] b)assuming int*[10] foo3; Foo3 is aliased to fooArray. By convention you could write foo3=&fooArray[0]; or foo3=cast(void*)fooArray[0]; whenever you convert an array to a mere pointer, in order to alert maintainers that some unsafe array operations with foo3 lie ahead. [But don't write "foo3=&fooArray;" it's a bug!] Now, let's combine D's implicit array to pointer conversion with the "memset" behaviour of the assigment operator: int [10] array; // Or was int*[10] array intended ? int*[10] fooArray; // looks like a memcopy, but actually a memset is performed ! fooArray[]=array[]; Maybe a I'd better forget about my D conventions, and go back to assembler commenting style for D. Farmer.
Mar 30 2003
I've saved this one as unread, and come back to it this morning. Nasty stuff. (I'm setting to unread again, as this'll need more thinking in the future.) Walter, I'd be interested in your comments on all the examples. "Farmer" <itsFarmer. freenet.de> wrote in message news:Xns934ED20ADBED6itsFarmer 63.105.9.61..."Matthew Wilson" <dmd synesis.com.au> wrote in news:b64c71$2rgd$1 digitaldaemon.com: [snip]If there's one criticism I'd make of the thrust of lots of arguments in this newsgroup, it is the focus on the convenience of code authors without much thought for code maintainers (even where coder === the maintainer)Here is some more stuff for upcoming D maintainerns to struggle with :-( int*[10] fooArray; fooArray[]=foo2; If you don't know foo2's type then you cannot guess what's happening: a) assuming int* foo2; fooArray is set to values of int* (like C memset). b) assuming int[9] foo2; The content of foo2 is copied to fooArray (like C memcopy). [Actually you get a runtime error "lengths don't match for array copy", for this example] By convention you could waste (read invest) 2 characters for writting fooArray[]=foo2[]; // xxx[]=xxx[] means "memcopy" whenever foo2 is an array in order to make things more obvious. int*[10] fooArray; foo3=fooArray; Again you don't know foo3's type. Then two very similar things could happen: a)assuming void* foo3; The address of fooArray's content is taken. [In case a) the writer might intended "foo3=fooArray[1];" instead of "foo3=fooArray;"] b)assuming int*[10] foo3; Foo3 is aliased to fooArray. By convention you could write foo3=&fooArray[0]; or foo3=cast(void*)fooArray[0]; whenever you convert an array to a mere pointer, in order to alert maintainers that some unsafe array operations with foo3 lie ahead. [But don't write "foo3=&fooArray;" it's a bug!] Now, let's combine D's implicit array to pointer conversion with the "memset" behaviour of the assigment operator: int [10] array; // Or was int*[10] array intended ? int*[10] fooArray; // looks like a memcopy, but actually a memset is performed ! fooArray[]=array[]; Maybe a I'd better forget about my D conventions, and go back to assembler commenting style for D. Farmer.
May 21 2003
There are some good ideas there. "Matthew Wilson" <matthew stlsoft.org> wrote in message news:bah9kg$kdi$1 digitaldaemon.com...I've saved this one as unread, and come back to it this morning. Nasty stuff. (I'm setting to unread again, as this'll need more thinking in the future.) Walter, I'd be interested in your comments on all the examples.
May 24 2003
Any responses on this one yet? "Walter" <walter digitalmars.com> wrote in message news:bapdri$gir$1 digitaldaemon.com...There are some good ideas there. "Matthew Wilson" <matthew stlsoft.org> wrote in message news:bah9kg$kdi$1 digitaldaemon.com...theI've saved this one as unread, and come back to it this morning. Nasty stuff. (I'm setting to unread again, as this'll need more thinking infuture.) Walter, I'd be interested in your comments on all the examples.
Jul 09 2003
"Matthew Wilson" <matthew stlsoft.org> wrote in message news:beid7n$jh2$2 digitaldaemon.com...Any responses on this one yet?Not yet!
Jul 10 2003
Ilya Minkov <midiclub tiscali.de> writes:Farmer wrote:Certainly the if () construct must only have boolean bit values. All right. The language _could_ have, for incurable C hackers and other friends of terse syntax, conversions such as -- hypothetical syntax: module global_conversions; void convert(Object object, out bit isNonNull) { isNonNull = object !== null; } void convert(int number, out bit isNonZero) { isNonZero = object !== 0; } and so on. And "if (object)" would automatically convert the object to bool. And by the way, I'd just *love* to have other user-defined conversions between different types as well. (Maybe this is asking too much - perhaps it's better to stop before the language starts to approach C++ in complexity, right?) -Anttiquite a suprise when their newly written D code crashes ! SomeClass obj; if (obj != null) // access violation when obj===null { // do sth. with obj } if (obj == null) // access violation when obj===null { obj=new SomeClass(); // init now }Wouldn't you normally write ?: if (obj) {} if (!obj) {}
Mar 29 2003
The language _could_ have, for incurable C hackers and other friends of terse syntax, conversions such as -- hypothetical syntax:...void convert(Object object, out bit isNonNull)...and so on. And "if (object)" would automatically convert the object to bool. And by the way, I'd just *love* to have other user-defined conversions between different types as well. (Maybe this is asking too much - perhaps it's better to stop before the language starts to approach C++ in complexity, right?) -AnttiSome of it *is* practical. All of it, unleashed, leads to horror you can see in C++. I cannot tell where the balance is, but I can tell you that many people use it and love it -- it's not just you alone. It is a valid need. Millions write that. And they are not all just stupid. (Implicit conversions between different number types are already done, and you'd laugh at a C-like language missing them. Most of the time, implicit conversion to boolean, if you look at it, is really just a tool to support checking for "object reliability". "Trueness", if you wish, not in the real bool sense, but regarding "trust".) People use "if (x)", because there is no better alternative. There *are* doznes of good alternatives, but things like if (x.initialized) may not be *better* alternatives in every cases, and they are -- despite being very common real-world problems -- definitely not standard and have no built-in support in practically any language. (Partly because it's not trivial to support.) (I'm a strong "believer" in the laws of phisics, like the minimum energy principle, and I also like doing things the most convenient and simple ways. As one Finnish civil engineer (I guess you know this better, Antti :) ) once designed a park: he let people walking across it for a while, and where they walked out the grass, there he finally put the paved passages...) Cheers, Luna Kid
Mar 29 2003
Ilya Minkov <midiclub tiscali.de> wrote in news:b61ii2$mft$1 digitaldaemon.com:Basically, you don't need to be able to compare an object with NULL (Warning!), but it may be requiered to be able to compare 2 objects by reference. However, it is much more intuitive to compare by contents. You write a==b to compare integers by contents, not by reference. So why should you make it all inconsistent and compare other things by reference? Forget of objects being pointers. They are objects. Simply that. [...]I don't buy that. I prefer to stick to the truth.BTW, with good exception handling, like the one D promises, NULL pointer dereferencing is not yet program's death. [...]To my best knowledge, D promises nothing when dereferencing "null objects". (a)my D compiler (DMD 0.58) does not do any checks (b)the D spec contains nothing about it (c)there is nothing like a nullPointerError in Phobos codeAnd you don't have to consider it in every line of a program. Your functions don't even have to yuild a dead object in first place - why don't you just raise your own exception and catch it on the upper level without cluttering your code with pointer checks? Dead object usually *is* an error indicator. An object which has been destroyed and then reused or simply stored away? Remember RAII. And aren't exceptions better because they almost don't slow down the normal case code?You are absolutely right on this. But it is difficult to stop people from doing such nonsense: I actually took the offending code, from a Java programm. It has been written by a professional programmer who has experience in Visual Basic, C, C++ and Java. Farmer.
Mar 30 2003
Cheers, mate. :) "Jon Allen" <jallen minotstateu.edu> wrote in message news:b5r8uf$2qhb$1 digitaldaemon.com...In article <b5r826$2pjt$1 digitaldaemon.com>, Matthew Wilson says...forIf I remember, last year there was debate on using == and === operatorsIfrepresenting equivalence and identity. Is this correct? Still the case?so, which one is which?=== is identity, while == is equivalence
Mar 25 2003