digitalmars.D - The Is Operator
- Kyle G. (16/16) Oct 02 2007 Hi,
- Bill Baxter (5/26) Oct 02 2007 Only reason is that it would require adding an extra keyword to the
- =?ISO-8859-1?Q?Anders_F_Bj=F6rklund?= (4/5) Oct 02 2007 What's the logical negation of a pointer, anyway ?
- Bill Baxter (4/9) Oct 04 2007 bool negated_pointer = !some_ptr;
- Janice Caron (11/19) Oct 04 2007 Technically speaking, what you've done there is implicitly cast your
- Kyle G. (2/31) Oct 02 2007 Doing !(key in map) definitely causes me distress.
- =?ISO-8859-1?Q?Anders_F_Bj=F6rklund?= (4/8) Oct 02 2007 A few hundred, search the newsgroup for more details...
- Kyle G. (3/15) Oct 02 2007 It's not that I hate it. In fact, I use !is all the time where it
- 0ffh (7/11) Oct 02 2007 I think the syntax is perfectly logical, because the negation applies to
- Gregor Richards (6/21) Oct 02 2007 Yeah, to me "a is not null" makes sense as an English sentence, but as
- Kirk McDonald (12/41) Oct 02 2007 I'd like to point out that "is not" is exactly what the Python
- Bill Baxter (6/46) Oct 02 2007 And also the binary boolean operators 'and' and 'or'.
- Lutger (3/9) Oct 03 2007 It took me a moment to realize this can be valid code. Perhaps it is the...
- 0ffh (4/8) Oct 02 2007 Well, "not in" seems okay but "is not" looks.... like wierd!
- Derek Parnell (7/11) Oct 02 2007 This gets discussed every 6-months or so ... my favourite replacement
- Chris Nicholson-Sauls (4/15) Oct 02 2007 Which reminds me, I need to petition for Ruby to have 'is'/'aint' added ...
- Robert Fraser (3/20) Oct 03 2007 From some experience in Perl, I can say unless(P) is slightly clearer th...
- Jarrett Billingsley (10/18) Oct 03 2007 Course you also get people who think it's "cute" to do something like
- Alexander Panek (2/4) Oct 03 2007 I vote for if (var uint null) !
- =?ISO-8859-1?Q?Anders_F_Bj=F6rklund?= (3/7) Oct 03 2007 I thought the "if (var out null)" was somewhat amusing too...
- Walter Bright (2/4) Oct 02 2007 It all depends on what the meaning of "is" is.
- Bill Baxter (4/9) Oct 02 2007 That's a good quote to go with your collection of famous things nobody
- Kyle G. (9/14) Oct 02 2007 That sounds like quote from a US politician.
- Robert Fraser (2/17) Oct 03 2007 Now _that's_ the sort of syntax feature we need to make D a major and re...
Hi, First time posting here on the NG, and certainly not my last. D has a good deal of syntactic sugar which results in easier to read code. However, there's one particular thing that has been bothering me for a while now: void foo(void[] var) { if (var !is null) // line of code } int main() { foo(null); } The code I am concerned about is "var !is null" which appears to translate to "var not is null" when it actually means "var is not null." Is there any special reason why we are unable to do "var isnot null" or "var is not null"?
Oct 02 2007
Kyle G. wrote:Hi, First time posting here on the NG, and certainly not my last. D has a good deal of syntactic sugar which results in easier to read code. However, there's one particular thing that has been bothering me for a while now: void foo(void[] var) { if (var !is null) // line of code } int main() { foo(null); } The code I am concerned about is "var !is null" which appears to translate to "var not is null" when it actually means "var is not null." Is there any special reason why we are unable to do "var isnot null" or "var is not null"?Only reason is that it would require adding an extra keyword to the language. More annoying to me is that !in doesn't work. --bb
Oct 02 2007
Bill Baxter wrote:More annoying to me is that !in doesn't work.What's the logical negation of a pointer, anyway ? But !in usually ranks high on the dwishlist thing. --anders
Oct 02 2007
Anders F Björklund wrote:Bill Baxter wrote:bool negated_pointer = !some_ptr; Seems pretty clear to me. --bbMore annoying to me is that !in doesn't work.What's the logical negation of a pointer, anyway ?
Oct 04 2007
On 10/4/07, Bill Baxter <dnewsgroup billbaxter.com> wrote:Anders F Björklund wrote:Technically speaking, what you've done there is implicitly cast your pointer to bool and _then_ logically negated it. Mathematically speaking, if -(-x) does not equal x then you can't call it a negation. It has to be self-inverse. Logical not has this property when applied to bools !(!x)== x. I think this is the point that Anders was making, with some good humor thrown in. You cannot take the logical not of a pointer. You have to cast it to bool first. Of course this is no problem. I'm just being mentioning this for the hell of it :-)Bill Baxter wrote:bool negated_pointer = !some_ptr; Seems pretty clear to me.More annoying to me is that !in doesn't work.What's the logical negation of a pointer, anyway ?
Oct 04 2007
Bill Baxter wrote:Kyle G. wrote:Doing !(key in map) definitely causes me distress.Hi, First time posting here on the NG, and certainly not my last. D has a good deal of syntactic sugar which results in easier to read code. However, there's one particular thing that has been bothering me for a while now: void foo(void[] var) { if (var !is null) // line of code } int main() { foo(null); } The code I am concerned about is "var !is null" which appears to translate to "var not is null" when it actually means "var is not null." Is there any special reason why we are unable to do "var isnot null" or "var is not null"?Only reason is that it would require adding an extra keyword to the language. More annoying to me is that !in doesn't work. --bb
Oct 02 2007
Kyle G. wrote:The code I am concerned about is "var !is null" which appears to translate to "var not is null" when it actually means "var is not null." Is there any special reason why we are unable to do "var isnot null" or "var is not null"?A few hundred, search the newsgroup for more details... If you hate it a lot, then just use "if (var)" instead. --anders
Oct 02 2007
Anders F Björklund wrote:Kyle G. wrote:It's not that I hate it. In fact, I use !is all the time where it applies. It just looks bad.The code I am concerned about is "var !is null" which appears to translate to "var not is null" when it actually means "var is not null." Is there any special reason why we are unable to do "var isnot null" or "var is not null"?A few hundred, search the newsgroup for more details... If you hate it a lot, then just use "if (var)" instead. --anders
Oct 02 2007
Kyle G. wrote:The code I am concerned about is "var !is null" which appears to translate to "var not is null" when it actually means "var is not null." Is there any special reason why we are unable to do "var isnot null" or "var is not null"?I think the syntax is perfectly logical, because the negation applies to the /operator/ and not the /operand/.Note the analogy of the statements: (p == null) <--> (p is null) (p != null) <--> (p !is null) Nobody would ever get try to write (i == !null), so why (i is not null)? Regards, Frank
Oct 02 2007
0ffh wrote:Kyle G. wrote:Yeah, to me "a is not null" makes sense as an English sentence, but as an operator it seems like "a is (not null)". (not null) would have to evaluate to ... 1? So this would be a is 1, which isn't what we want at all. Suffice to say D !is English. - Gregor RichardsThe code I am concerned about is "var !is null" which appears to translate to "var not is null" when it actually means "var is not null." Is there any special reason why we are unable to do "var isnot null" or "var is not null"?I think the syntax is perfectly logical, because the negation applies to the /operator/ and not the /operand/.Note the analogy of the statements: (p == null) <--> (p is null) (p != null) <--> (p !is null) Nobody would ever get try to write (i == !null), so why (i is not null)? Regards, Frank
Oct 02 2007
Gregor Richards wrote:0ffh wrote:I'd like to point out that "is not" is exactly what the Python equivalent of "!is" is. http://docs.python.org/ref/comparisons.html if a is not None: foo() Likewise, it also uses "not in". -- Kirk McDonald http://kirkmcdonald.blogspot.com Pyd: Connecting D and Python http://pyd.dsource.orgKyle G. wrote:Yeah, to me "a is not null" makes sense as an English sentence, but as an operator it seems like "a is (not null)". (not null) would have to evaluate to ... 1? So this would be a is 1, which isn't what we want at all. Suffice to say D !is English. - Gregor RichardsThe code I am concerned about is "var !is null" which appears to translate to "var not is null" when it actually means "var is not null." Is there any special reason why we are unable to do "var isnot null" or "var is not null"?I think the syntax is perfectly logical, because the negation applies to the /operator/ and not the /operand/.Note the analogy of the statements: (p == null) <--> (p is null) (p != null) <--> (p !is null) Nobody would ever get try to write (i == !null), so why (i is not null)? Regards, Frank
Oct 02 2007
Kirk McDonald wrote:Gregor Richards wrote:And also the binary boolean operators 'and' and 'or'. if you is not None and I is not finished or they is happy: goto_skool() See reads just like English! --bb0ffh wrote:I'd like to point out that "is not" is exactly what the Python equivalent of "!is" is. http://docs.python.org/ref/comparisons.html if a is not None: foo() Likewise, it also uses "not in".Kyle G. wrote:Yeah, to me "a is not null" makes sense as an English sentence, but as an operator it seems like "a is (not null)". (not null) would have to evaluate to ... 1? So this would be a is 1, which isn't what we want at all. Suffice to say D !is English. - Gregor RichardsThe code I am concerned about is "var !is null" which appears to translate to "var not is null" when it actually means "var is not null." Is there any special reason why we are unable to do "var isnot null" or "var is not null"?I think the syntax is perfectly logical, because the negation applies to the /operator/ and not the /operand/.Note the analogy of the statements: (p == null) <--> (p is null) (p != null) <--> (p !is null) Nobody would ever get try to write (i == !null), so why (i is not null)? Regards, Frank
Oct 02 2007
Bill Baxter wrote:if you is not None and I is not finished or they is happy: goto_skool() See reads just like English! --bbIt took me a moment to realize this can be valid code. Perhaps it is the lack of syntax highlighting, but as code, it is hard to read for me.
Oct 03 2007
Kirk McDonald wrote:I'd like to point out that "is not" is exactly what the Python equivalent of "!is" is. [...] Likewise, it also uses "not in".Well, "not in" seems okay but "is not" looks.... like wierd! Let "not" be a prefix, and a prefix always, lest you flummox the coder! :) Regards, Frank
Oct 02 2007
On Tue, 02 Oct 2007 17:23:48 -0400, Kyle G. wrote:The code I am concerned about is "var !is null" which appears to translate to "var not is null" when it actually means "var is not null." Is there any special reason why we are unable to do "var isnot null" or "var is not null"?This gets discussed every 6-months or so ... my favourite replacement keyword so far is "aint" as in "if (var aint null) " :-) -- Derek Parnell Melbourne, Australia skype: derek.j.parnell
Oct 02 2007
Derek Parnell wrote:On Tue, 02 Oct 2007 17:23:48 -0400, Kyle G. wrote:Which reminds me, I need to petition for Ruby to have 'is'/'aint' added to it. They've already got 'unless' and 'until', so why not? -- Chris Nicholson-SaulsThe code I am concerned about is "var !is null" which appears to translate to "var not is null" when it actually means "var is not null." Is there any special reason why we are unable to do "var isnot null" or "var is not null"?This gets discussed every 6-months or so ... my favourite replacement keyword so far is "aint" as in "if (var aint null) " :-)
Oct 02 2007
Chris Nicholson-Sauls Wrote:Derek Parnell wrote:From some experience in Perl, I can say unless(P) is slightly clearer than if(!P) and until(P) is slightly clearer than while(!P) ... in most cases. I'm not arguing it should be added to D (esp. since if there are multiple ways to express something, stuff can get confusing), but they _do_ make code just that much easier to read. On that note, I'm also a slight fan of the postfix notation for simple ifs (i.e. something like "a = b if b;" or "file.read() while file.hasMoreBytes();"), but it makes parsing a *****.On Tue, 02 Oct 2007 17:23:48 -0400, Kyle G. wrote:Which reminds me, I need to petition for Ruby to have 'is'/'aint' added to it. They've already got 'unless' and 'until', so why not? -- Chris Nicholson-SaulsThe code I am concerned about is "var !is null" which appears to translate to "var not is null" when it actually means "var is not null." Is there any special reason why we are unable to do "var isnot null" or "var is not null"?This gets discussed every 6-months or so ... my favourite replacement keyword so far is "aint" as in "if (var aint null) " :-)
Oct 03 2007
"Robert Fraser" <fraserofhenight gmail.com> wrote in message news:fdvg0m$2c3e$1 digitalmars.com...From some experience in Perl, I can say unless(P) is slightly clearer than if(!P) and until(P) is slightly clearer than while(!P) ... in most cases. I'm not arguing it should be added to D (esp. since if there are multiple ways to express something, stuff can get confusing), but they _do_ make code just that much easier to read. On that note, I'm also a slight fan of the postfix notation for simple ifs (i.e. something like "a = b if b;" or "file.read() while file.hasMoreBytes();"), but it makes parsing a *****.Course you also get people who think it's "cute" to do something like while(someCondition) { ..... 3 pages of code... ..... } if(someOtherCondition)
Oct 03 2007
Derek Parnell wrote:This gets discussed every 6-months or so ... my favourite replacement keyword so far is "aint" as in "if (var aint null) " :-)I vote for if (var uint null) !
Oct 03 2007
Alexander Panek wrote:I thought the "if (var out null)" was somewhat amusing too... --andersThis gets discussed every 6-months or so ... my favourite replacement keyword so far is "aint" as in "if (var aint null) " :-)I vote for if (var uint null) !
Oct 03 2007
Kyle G. wrote:Is there any special reason why we are unable to do "var isnot null" or "var is not null"?It all depends on what the meaning of "is" is.
Oct 02 2007
Walter Bright wrote:Kyle G. wrote:That's a good quote to go with your collection of famous things nobody ever said about D. You can attribute it to Dill Dinton. --bb, hoping you don't take this suggestion seriously.Is there any special reason why we are unable to do "var isnot null" or "var is not null"?It all depends on what the meaning of "is" is.
Oct 02 2007
Walter Bright wrote:Kyle G. wrote:That sounds like quote from a US politician. And so without 'is,' ... In this context, the first 'is' attempts to discern whether their exists a known accepted justification for the usage of "!is" as opposed to something potentially cleaner and easier to read. It appears the justification which has been applied here follows that an extra keyword in the language would not be necessary when existing language keywords suffice.Is there any special reason why we are unable to do "var isnot null" or "var is not null"?It all depends on what the meaning of "is" is.
Oct 02 2007
Derek Parnell Wrote:On Tue, 02 Oct 2007 17:23:48 -0400, Kyle G. wrote:Now _that's_ the sort of syntax feature we need to make D a major and respected player in the software engineering world.The code I am concerned about is "var !is null" which appears to translate to "var not is null" when it actually means "var is not null." Is there any special reason why we are unable to do "var isnot null" or "var is not null"?This gets discussed every 6-months or so ... my favourite replacement keyword so far is "aint" as in "if (var aint null) " :-) -- Derek Parnell Melbourne, Australia skype: derek.j.parnell
Oct 03 2007