digitalmars.D - Proposal: isnot
- Achilleas Margaritis (6/6) May 09 2004 I am currently writing some GUI application with D, and I found it is
- Matthew (5/11) May 09 2004 What's wrong with
- resistor AT nospam DOT mac DOT com (7/22) May 09 2004 As I recall, the specification seems to imply (incorrectly?) that one mu...
- Matthew (1/29) May 09 2004
- Andrew Edwards (7/23) May 09 2004 I'd say the same thing that's wrong with
- Matthew (3/26) May 09 2004 No, I don't see much wrong either. Was just being orthogonal.
- Bruno A. Costa (4/9) May 10 2004 Agreed. I didn't like the "isnot" operator. "is not" is much better,
- Kris (6/8) May 22 2004 Why the need for an 'is' token for !== equivalence?
- Hauke Duden (10/17) May 09 2004 I agree. It's not a critical issue, but having something like isnot
- Mike Swieton (7/14) May 09 2004 I'll throw in a vote for this. If === has !==, then is should have isnot...
- Mr. Negative (4/6) May 09 2004
- Mike Swieton (14/16) May 09 2004 This is certainly a valid consideration, but I disagree. Firstly, becaus...
- Achilleas Margaritis (14/30) May 09 2004 items in
- Walter (5/11) May 09 2004 ?
- Unknown W. Brackets (7/17) May 09 2004 I would prefer:
- J C Calvarese (8/33) May 09 2004 I don't like that so much (especially not "==="). But they're a whole
- Helmut Leitner (11/15) May 09 2004 If I would dislike such things (which I don't) then I would
- Hauke Duden (10/29) May 10 2004 Urgh! You propose that the built-in syntax should not be used and one
- Unknown W. Brackets (9/43) May 11 2004 I agree, if someone must have their ugly code they can. D doesn't stop
- Helmut Leitner (10/20) May 11 2004 You don't know what you are talking about.
- Juan C (5/5) May 11 2004 If == is for testing the contents and === is for testing the address, th...
- James McComb (9/11) May 11 2004 This IsNull property idea intrigues me (no foolin', this time).
- J Anderson (5/17) May 11 2004 Might as well define your own function to do it:
- James McComb (8/12) May 11 2004 Sure, you could that.
- J Anderson (8/20) May 12 2004 I don't think there should be any sort of alias for testing null like
- Derek Parnell (9/27) May 11 2004 The D compiler would have to treat such a property differently than othe...
- James McComb (5/12) May 12 2004 Thanks for this explanation.
- Tu Nam (8/14) May 09 2004 Well so D will become DASIC , not just D.
- JamesMcComb (5/10) May 10 2004 +1 for this proposal if the operator becomes ain't.
- J Anderson (4/15) May 10 2004 Is this a joke? The ' would cause also kinds of parsing errors.
- J C Calvarese (5/28) May 10 2004 I reckon that the parsin' would be all mussed up by that.
- Phill (5/30) May 11 2004 D
- Unknown W. Brackets (4/10) May 11 2004 I concur.
- Phill (7/16) May 11 2004 'foo
- clayasaurus (6/18) Mar 05 2005 with it.
- =?UTF-8?B?QW5kZXJzIEYgQmrDtnJrbHVuZA==?= (12/15) Mar 06 2005 You mean like:
- Matthew (4/18) Mar 06 2005 I don't recall it being settled. I doubt it'll change, but you're never ...
- =?ISO-8859-1?Q?Anders_F_Bj=F6rklund?= (22/30) Mar 06 2005 I think the (now deprecated?) version that Mango uses is the best:
- Ben Hinkle (7/22) Mar 06 2005 FWIW in my code I use x !== y instead of !(x is y). I think it is easier...
I am currently writing some GUI application with D, and I found it is tiresome and errorprone to write !(foo is null) all the time. I think D would benefit from an 'isnot' operator. If it existed, I could write 'foo isnot null' and be more productive, since it is easy to forget the ! and makes the code more beautiful since less parentheses are needed. It is a small change, easily done in my opinion. What do you think, Walter ?
May 09 2004
What's wrong with if(null !== foo) ? "Achilleas Margaritis" <axilmar b-online.gr> wrote in message news:c7lb26$1skj$1 digitaldaemon.com...I am currently writing some GUI application with D, and I found it is tiresome and errorprone to write !(foo is null) all the time. I think D would benefit from an 'isnot' operator. If it existed, I could write 'foo isnot null' and be more productive, since it is easy to forget the ! and makes the code more beautiful since less parentheses are needed. It is a small change, easily done in my opinion. What do you think, Walter ?
May 09 2004
As I recall, the specification seems to imply (incorrectly?) that one must always compare against null with the 'is' operator. Is this incorrect? If so, I think we may need to reexamine the spec because it seems like a certain percentage of people are misreading it. Owen In article <c7lcfs$1ugj$1 digitaldaemon.com>, Matthew says...What's wrong with if(null !== foo) ? "Achilleas Margaritis" <axilmar b-online.gr> wrote in message news:c7lb26$1skj$1 digitaldaemon.com...I am currently writing some GUI application with D, and I found it is tiresome and errorprone to write !(foo is null) all the time. I think D would benefit from an 'isnot' operator. If it existed, I could write 'foo isnot null' and be more productive, since it is easy to forget the ! and makes the code more beautiful since less parentheses are needed. It is a small change, easily done in my opinion. What do you think, Walter ?
May 09 2004
As I recall, the specification seems to imply (incorrectly?) that one must always compare against null with the 'is' operator. Is this incorrect? If so, I think we may need to reexamine the spec because it seems like a certain percentage of people are misreading it.If that is so, then I am certainly one making such a mistakeOwen In article <c7lcfs$1ugj$1 digitaldaemon.com>, Matthew says...What's wrong with if(null !== foo) ? "Achilleas Margaritis" <axilmar b-online.gr> wrote in message news:c7lb26$1skj$1 digitaldaemon.com...I am currently writing some GUI application with D, and I found it is tiresome and errorprone to write !(foo is null) all the time. I think D would benefit from an 'isnot' operator. If it existed, I could write 'foo isnot null' and be more productive, since it is easy to forget the ! and makes the code more beautiful since less parentheses are needed. It is a small change, easily done in my opinion. What do you think, Walter ?
May 09 2004
Matthew wrote:What's wrong with if(null !== foo) ?I'd say the same thing that's wrong with if(foo === null) // as opposed to if(foo is null) Absolutely nothing! Except that it is clearer and less errorprone. Quite frankly I don't see much of a problem with the proposal. Of course I'm not the one engineering this beast, so I'll leave it up to the big boys to decide."Achilleas Margaritis" <axilmar b-online.gr> wrote in message news:c7lb26$1skj$1 digitaldaemon.com...I am currently writing some GUI application with D, and I found it is tiresome and errorprone to write !(foo is null) all the time. I think D would benefit from an 'isnot' operator. If it existed, I could write 'foo isnot null' and be more productive, since it is easy to forget the ! and makes the code more beautiful since less parentheses are needed. It is a small change, easily done in my opinion. What do you think, Walter ?
May 09 2004
Matthew wrote:No, I don't see much wrong either. Was just being orthogonal. However, I don't like isnot. I'd prefer "is not". I'd also like to be able to use "not" with "in" for searching containers.What's wrong with if(null !== foo) ?I'd say the same thing that's wrong with if(foo === null) // as opposed to if(foo is null) Absolutely nothing! Except that it is clearer and less errorprone. Quite frankly I don't see much of a problem with the proposal. Of course I'm not the one engineering this beast, so I'll leave it up to the big boys to decide."Achilleas Margaritis" <axilmar b-online.gr> wrote in message news:c7lb26$1skj$1 digitaldaemon.com...I am currently writing some GUI application with D, and I found it is tiresome and errorprone to write !(foo is null) all the time. I think D would benefit from an 'isnot' operator. If it existed, I could write 'foo isnot null' and be more productive, since it is easy to forget the ! and makes the code more beautiful since less parentheses are needed. It is a small change, easily done in my opinion. What do you think, Walter ?
May 09 2004
Matthew wrote:However, I don't like isnot. I'd prefer "is not". I'd also like to be able to use "not" with "in" for searching containers.Agreed. I didn't like the "isnot" operator. "is not" is much better, IMHO. Bruno.
May 10 2004
Why the need for an 'is' token for !== equivalence? Simply using "not", as in (x not null) would seem reasonably orthogonal to (x is null), and Walter would presumably be able to reuse the "not" keyword elsewhere (alongside "in", as you suggest). - Kris "Matthew" <matthew.hat stlsoft.dot.org> wroteHowever, I don't like isnot. I'd prefer "is not". I'd also like to be able to use "not" with "in" for searching containers.
May 22 2004
Achilleas Margaritis wrote:I am currently writing some GUI application with D, and I found it is tiresome and errorprone to write !(foo is null) all the time. I think D would benefit from an 'isnot' operator. If it existed, I could write 'foo isnot null' and be more productive, since it is easy to forget the ! and makes the code more beautiful since less parentheses are needed. It is a small change, easily done in my opinion. What do you think, Walter ?I agree. It's not a critical issue, but having something like isnot would certainly improve readability (even if it sounds like a new kind of tissue that was designed by Apple ;)). D already has too many round parentheses in complex expressions anyway, even more than C++ because they are also used for templates. Getting rid of some of them will certainly be an improvement. Besides, not having a negative version of "is" is inconsistent, since == also has one. Hauke
May 09 2004
On Sun, 09 May 2004 16:18:01 +0300, Achilleas Margaritis wrote:I am currently writing some GUI application with D, and I found it is tiresome and errorprone to write !(foo is null) all the time. I think D would benefit from an 'isnot' operator. If it existed, I could write 'foo isnot null' and be more productive, since it is easy to forget the ! and makes the code more beautiful since less parentheses are needed. It is a small change, easily done in my opinion. What do you think, Walter ?I'll throw in a vote for this. If === has !==, then is should have isnot. It would be more consistent. Mike Swieton __ Dare to be naive. - Buckminster Fuller
May 09 2004
<snip>I'll throw in a vote for this. If === has !==, then is should have isnot. It would be more consistent.</snip> I'd rather get rid of "is" and have === and !== . The fewer "English" items in the language the better.
May 09 2004
On Sun, 09 May 2004 17:22:56 +0000, Mr.Negative wrote:I'd rather get rid of "is" and have === and !== . The fewer "English" items in the language the better.This is certainly a valid consideration, but I disagree. Firstly, because 'is' is already there. I don't think there's a compelling enough reason to break code by removing it. Secondly, I like the english operators better than their symbol counterparts mostly because I think === gets a bit excessive. I understand the use of == over =, but I think that three equals characters is excessive. It is asking for bugs from typos, because it's misuse cannot be detected by the compiler. Do I think it's a big issue? No. But I think it is a big enough one to warrant inclusion, seeing as how it is a small change. Mike Swieton __ If the government wants us to respect the law, they should set a better example.
May 09 2004
"Mike Swieton" <mike swieton.net> wrote in message news:pan.2004.05.09.17.38.26.464217 swieton.net...On Sun, 09 May 2004 17:22:56 +0000, Mr.Negative wrote:items inI'd rather get rid of "is" and have === and !== . The fewer "English"'is'the language the better.This is certainly a valid consideration, but I disagree. Firstly, becauseis already there. I don't think there's a compelling enough reason tobreakcode by removing it. Secondly, I like the english operators better thantheirsymbol counterparts mostly because I think === gets a bit excessive. I understand the use of == over =, but I think that three equals charactersisexcessive. It is asking for bugs from typos, because it's misuse cannot be detected by the compiler. Do I think it's a big issue? No. But I think it is a big enough one towarrantinclusion, seeing as how it is a small change. Mike Swieton __ If the government wants us to respect the law, they should set a better example.It is very easy to make a mistake with '===' and '=='. After lots of D typing, I found out that I should not use '==='; I should always use 'is', because it is much clearer that I check for identity. It is not a big issue. I think Walter will spend about 10 minutes to incorporate this into the language. But it will save developers lots of time, otherwise spent in tracking down silly typing mistakes.
May 09 2004
"Achilleas Margaritis" <axilmar b-online.gr> wrote in message news:c7lb26$1skj$1 digitaldaemon.com...I am currently writing some GUI application with D, and I found it is tiresome and errorprone to write !(foo is null) all the time. I think D would benefit from an 'isnot' operator. If it existed, I could write 'foo isnot null' and be more productive, since it is easy to forget the ! and makes the code more beautiful since less parentheses are needed. It is a small change, easily done in my opinion. What do you think, Walter? It is a small change and easilly done, but once made, we're stuck with it. I'd like to run with the current scheme for a while longer first.
May 09 2004
Achilleas Margaritis wrote:I am currently writing some GUI application with D, and I found it is tiresome and errorprone to write !(foo is null) all the time. I think D would benefit from an 'isnot' operator. If it existed, I could write 'foo isnot null' and be more productive, since it is easy to forget the ! and makes the code more beautiful since less parentheses are needed. It is a small change, easily done in my opinion. What do you think, Walter ?I would prefer: a !is b And: a !== b But that's just my personal opinion. -[Unknown]
May 09 2004
Unknown W. Brackets wrote:Achilleas Margaritis wrote:I like that.I am currently writing some GUI application with D, and I found it is tiresome and errorprone to write !(foo is null) all the time. I think D would benefit from an 'isnot' operator. If it existed, I could write 'foo isnot null' and be more productive, since it is easy to forget the ! and makes the code more beautiful since less parentheses are needed. It is a small change, easily done in my opinion. What do you think, Walter ?I would prefer: a !is bAnd: a !== bI don't like that so much (especially not "==="). But they're a whole bunch more consistant with D than "isnot" or "not is". I like BASIC okay, but I don't want D to morph into BASIC.But that's just my personal opinion. -[Unknown]-- Justin (a/k/a jcc7) http://jcc_7.tripod.com/d/
May 09 2004
"Unknown W. Brackets" wrote:a === null a !== null a === b a !== bIf I would dislike such things (which I don't) then I would write the equivalent of C macros (D functions optimized away): IsNull(a) NotNull(a) PtrEqu(a,b) PtrCmp(a,b) Best done as part of the standard library. -- Helmut Leitner leitner hls.via.at Graz, Austria www.hls-software.com
May 09 2004
Helmut Leitner wrote:"Unknown W. Brackets" wrote:Urgh! You propose that the built-in syntax should not be used and one should have to create functions for these most basic operations? I would much rather have the normal syntax be readable and not rely on a library to fix a design fault. I also don't think that PtrEqu(a,b) is particularly well readable. The Windows API does this kind of thing a lot and IMHO this is merely the lesser of two evils in most cases. Better use the good solution while you still can. Haukea === null a !== null a === b a !== bIf I would dislike such things (which I don't) then I would write the equivalent of C macros (D functions optimized away): IsNull(a) NotNull(a) PtrEqu(a,b) PtrCmp(a,b) Best done as part of the standard library.
May 10 2004
Hauke Duden wrote:Helmut Leitner wrote:Heh, I did?"Unknown W. Brackets" wrote:a === null a !== null a === b a !== bI agree, if someone must have their ugly code they can. D doesn't stop that, nor does any other language. I like studlyCaps myself though.If I would dislike such things (which I don't) then I would write the equivalent of C macros (D functions optimized away): IsNull(a) NotNull(a) PtrEqu(a,b) PtrCmp(a,b) Best done as part of the standard library.Urgh! You propose that the built-in syntax should not be used and one should have to create functions for these most basic operations? I would much rather have the normal syntax be readable and not rely on a library to fix a design fault. I also don't think that PtrEqu(a,b) is particularly well readable. The Windows API does this kind of thing a lot and IMHO this is merely the lesser of two evils in most cases. Better use the good solution while you still can. HaukeNo, not at all. I read it as, "if they are freako VB programmers they can write hateful looking code... no reason to punish us all with ugly code for just the poor VB'ers" except not in those words or probably even exact meaning. -[Unknown]
May 11 2004
"Unknown W. Brackets" wrote:...If I would dislike such things (which I don't) then I would write the equivalent of C macros (D functions optimized away): IsNull(a) NotNull(a)You don't know what you are talking about. Function call syntax isn't more or less ugly than operator syntax. Is {/} uglier than begin/end? Is != uglier than <>? You just get have to get used to it, that's all. Important is: to be able to do your job with a minimum of complexity. -- Helmut Leitner leitner hls.via.at Graz, Austria www.hls-software.comI agree, if someone must have their ugly code they can.Best done as part of the standard library.
May 11 2004
If == is for testing the contents and === is for testing the address, then "is" shouldn't be one of those -- oh wouldn't it be neat if "is" were used to test the type of the item: if ( x is int ) ... I don't think an operator that's for testing for one special situation is very useful, I would prefer a property: MyRef.IsNull
May 11 2004
Juan C wrote:I don't think an operator that's for testing for one special situation is very useful, I would prefer a property: MyRef.IsNullThis IsNull property idea intrigues me (no foolin', this time). But it should probably be isNull, rather than IsNull. It could be defined for all object references. Example: /* x is an object reference */ if (!x.isNull) { //etc.. } What do you think? James McComb
May 11 2004
James McComb wrote:Juan C wrote:Might as well define your own function to do it: if (!isNull(x)) -- -Anderson: http://badmama.com.au/~anderson/I don't think an operator that's for testing for one special situation is very useful, I would prefer a property: MyRef.IsNullThis IsNull property idea intrigues me (no foolin', this time). But it should probably be isNull, rather than IsNull. It could be defined for all object references. Example: /* x is an object reference */ if (!x.isNull) { //etc.. } What do you think? James McComb
May 11 2004
J Anderson wrote:Might as well define your own function to do it: if (!isNull(x))Sure, you could that. But isNull is a function that a. is used extremely often b. is well-defined for all references. If there was an isNull property, I'd use it. Otherwise !== is fine by me. James McComb
May 11 2004
James McComb wrote:J Anderson wrote:I don't think there should be any sort of alias for testing null like your talking about. If you wanted to do it yourself you could always put it in your common tools lib (that you carry around and use with all code your write). All adding a .isNull property is doing is making the language harder to learn. -- -Anderson: http://badmama.com.au/~anderson/Might as well define your own function to do it: if (!isNull(x))Sure, you could that. But isNull is a function that a. is used extremely often b. is well-defined for all references. If there was an isNull property, I'd use it. Otherwise !== is fine by me. James McComb
May 12 2004
On Wed, 12 May 2004 13:29:02 +1000, James McComb wrote:Juan C wrote:The D compiler would have to treat such a property differently than other properties. Normally it would use 'x' as a reference to an object and inspect its property value. But in this case, 'x' may not be a valid reference. So even though it looks like a property it is really a pseudo one that the compiler treats differently. -- Derek 12/May/04 3:42:32 PMI don't think an operator that's for testing for one special situation is very useful, I would prefer a property: MyRef.IsNullThis IsNull property idea intrigues me (no foolin', this time). But it should probably be isNull, rather than IsNull. It could be defined for all object references. Example: /* x is an object reference */ if (!x.isNull) { //etc.. } What do you think? James McComb
May 11 2004
James McComb wrote:Derek Parnell wrote:This IsNull property idea intrigues me (no foolin', this time). But it should probably be isNull, rather than IsNull.>The D compiler would have to treat such a property differently than other properties. Normally it would use 'x' as a reference to an object and inspect its property value. But in this case, 'x' may not be a valid reference. So even though it looks like a property it is really a pseudo one that the compiler treats differently.Thanks for this explanation. OK, so it's not worth introducing an isNull property. James McComb
May 12 2004
Well so D will become DASIC , not just D. Basic has them all . Is , Not , TypeOf etc ... I don't think we would implement more English word in a programming language , let's it has something common for everyone . != and == are good . If we want code more clean , why don't we implement isEqual() and notEqual() in our object "Achilleas Margaritis" <axilmar b-online.gr> wrote in message news:c7lb26$1skj$1 digitaldaemon.com...I am currently writing some GUI application with D, and I found it is tiresome and errorprone to write !(foo is null) all the time. I think D would benefit from an 'isnot' operator. If it existed, I could write 'foo isnot null' and be more productive, since it is easy to forget the ! and makes the code more beautiful since less parentheses are needed. It is a small change, easily done in my opinion. What do you think, Walter?
May 09 2004
Achilleas Margaritis wrote:I am currently writing some GUI application with D, and I found it is tiresome and errorprone to write !(foo is null) all the time. I think D would benefit from an 'isnot' operator. If it existed, I could write 'foo isnot null' and be more productive, since it is easy to forget the ! and makes the code more beautiful since less parentheses are needed.+1 for this proposal if the operator becomes ain't. Example: if(a ain't b) // etc.. James McComb
May 10 2004
JamesMcComb wrote:Achilleas Margaritis wrote:Is this a joke? The ' would cause also kinds of parsing errors. -- -Anderson: http://badmama.com.au/~anderson/I am currently writing some GUI application with D, and I found it is tiresome and errorprone to write !(foo is null) all the time. I think D would benefit from an 'isnot' operator. If it existed, I could write 'foo isnot null' and be more productive, since it is easy to forget the ! and makes the code more beautiful since less parentheses are needed.+1 for this proposal if the operator becomes ain't. Example: if(a ain't b) // etc.. James McComb
May 10 2004
J Anderson wrote:JamesMcComb wrote:I reckon that the parsin' would be all mussed up by that. -- Justin (a/k/a jcc7) http://jcc_7.tripod.com/d/Achilleas Margaritis wrote:Is this a joke? The ' would cause also kinds of parsing errors.I am currently writing some GUI application with D, and I found it is tiresome and errorprone to write !(foo is null) all the time. I think D would benefit from an 'isnot' operator. If it existed, I could write 'foo isnot null' and be more productive, since it is easy to forget the ! and makes the code more beautiful since less parentheses are needed.+1 for this proposal if the operator becomes ain't. Example: if(a ain't b) // etc.. James McComb
May 10 2004
"J C Calvarese" <jcc7 cox.net> wrote in message news:c7pkr1$23lg$1 digitaldaemon.com...J Anderson wrote:DJamesMcComb wrote:Achilleas Margaritis wrote:I am currently writing some GUI application with D, and I found it is tiresome and errorprone to write !(foo is null) all the time. I thinkandwould benefit from an 'isnot' operator. If it existed, I could write 'foo isnot null' and be more productive, since it is easy to forget the !LOLI reckon that the parsin' would be all mussed up by that.Is this a joke? The ' would cause also kinds of parsing errors.makes the code more beautiful since less parentheses are needed.+1 for this proposal if the operator becomes ain't. Example: if(a ain't b) // etc.. James McComb
May 11 2004
JamesMcComb wrote:+1 for this proposal if the operator becomes ain't. Example: if(a ain't b) // etc.. James McCombI concur. +1 -[Unknown]
May 11 2004
"JamesMcComb" <alan jamesmccomb.id.au> wrote in message news:c7ph9t$1u2a$1 digitaldaemon.com...Achilleas Margaritis wrote:'fooI am currently writing some GUI application with D, and I found it is tiresome and errorprone to write !(foo is null) all the time. I think D would benefit from an 'isnot' operator. If it existed, I could writeAre you an Aussie? LOL You might not believe this, but I was going to reply to Mathews post with this same suggestion the other day. Phill.isnot null' and be more productive, since it is easy to forget the ! and makes the code more beautiful since less parentheses are needed.+1 for this proposal if the operator becomes ain't. Example: if(a ain't b) // etc..
May 11 2004
Walter wrote:"Achilleas Margaritis" <axilmar b-online.gr> wrote in message news:c7lb26$1skj$1 digitaldaemon.com...WalterI am currently writing some GUI application with D, and I found it is tiresome and errorprone to write !(foo is null) all the time. I think D would benefit from an 'isnot' operator. If it existed, I could write 'foo isnot null' and be more productive, since it is easy to forget the ! and makes the code more beautiful since less parentheses are needed. It is a small change, easily done in my opinion. What do you think,? It is a small change and easilly done, but once made, we're stuckwith it.I'd like to run with the current scheme for a while longer first.Just curious, how much while longer are you thinking? pre or post 1.0? will there be some kind of poll on which 'is not' operator is the best for D?
Mar 05 2005
clayasaurus wrote:will there be some kind of poll on which 'is not' operator is the best for D?You mean like: a) foo !== null b) foo c) !(foo is null) d) foo isnot null e) foo ~is null f) foo ≢ null g) foo || die h) foo ain't nuthin' I thought this issue was all settled, in favor of the terse option b):assert(foo);--anders
Mar 06 2005
"Anders F Björklund" <afb algonet.se> wrote in message news:d0edhj$2f76$1 digitaldaemon.com...clayasaurus wrote:I don't recall it being settled. I doubt it'll change, but you're never going to see any of my code with implicit boolean sub-expressions. :-(will there be some kind of poll on which 'is not' operator is the best for D?You mean like: a) foo !== null b) foo c) !(foo is null) d) foo isnot null e) foo ~is null f) foo ? null g) foo || die h) foo ain't nuthin' I thought this issue was all settled, in favor of the terse option b):assert(foo);--anders
Mar 06 2005
Matthew wrote:I think the (now deprecated?) version that Mango uses is the best: assert(foo !== null); It's a little dangerous, since you can easily mix it up with '!='... (especially if coming from e.g. Java, and being used to that form ?) But I find the "supported" way of writing to be too long and inverse: assert(!(foo is null)); However, it doesn't seem like D will ever get 'boolean' (nor 'String') Fortunately we can still use "bool" and the "long forms", and pretend... bool a = true; bool b = integer != 0; bool c = pointer != null; Some D parts assumes the "short forms", though, like "in" and "cast". These expressions tend to look somewhat cumbersome: if (!((key in hash) is null)) { ... } // AA lookup if (!((cast(C) obj) is null)) { ... } // instanceof Compared to the D forms possible, without booleans: if (key in hash) { ... } if (cast(C) obj) { ... } But I rather have the old-fashioned limonade, than sulk over lemons? Which in the end probably means writing C-style conditionals, to me. --andersI thought this issue was all settled, in favor of the terse option b):I don't recall it being settled. I doubt it'll change, but you're never going to see any of my code with implicit boolean sub-expressions. :-(assert(foo);
Mar 06 2005
In article <d0edhj$2f76$1 digitaldaemon.com>, =?UTF-8?B?QW5kZXJzIEYgQmrDtnJrbHVuZA==?= says...clayasaurus wrote:FWIW in my code I use x !== y instead of !(x is y). I think it is easier on my tired little brain to process !== over first processing "is" and then the !. I do use "is" instead of ===, though since === is too many equal signs in a row and it looks kinda ugly. Plus "is" has one fewer character. -Benwill there be some kind of poll on which 'is not' operator is the best for D?You mean like: a) foo !== null b) foo c) !(foo is null) d) foo isnot null e) foo ~is null f) foo ≢ null g) foo || die h) foo ain't nuthin' I thought this issue was all settled, in favor of the terse option b):assert(foo);--anders
Mar 06 2005