Jump to page: 1 2 3
Thread overview
The Is Operator
Oct 02, 2007
Kyle G.
Oct 02, 2007
Bill Baxter
Oct 04, 2007
Bill Baxter
Oct 04, 2007
Janice Caron
Oct 02, 2007
Kyle G.
Oct 02, 2007
Kyle G.
Oct 02, 2007
0ffh
Oct 02, 2007
Gregor Richards
Oct 02, 2007
Kirk McDonald
Oct 02, 2007
Bill Baxter
Oct 03, 2007
Lutger
Oct 03, 2007
0ffh
Oct 02, 2007
Derek Parnell
[OT] Re: The Is Operator
Oct 03, 2007
Robert Fraser
Oct 03, 2007
Alexander Panek
Oct 02, 2007
Walter Bright
Oct 03, 2007
Bill Baxter
Oct 03, 2007
Kyle G.
October 02, 2007
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"?
October 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
October 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
October 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
October 02, 2007
Bill Baxter wrote:
> 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

Doing !(key in map) definitely causes me distress.

October 02, 2007
Anders F Björklund wrote:
> 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


It's not that I hate it. In fact, I use !is all the time where it applies. It just looks bad.
October 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
October 02, 2007
0ffh wrote:
> 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

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 Richards
October 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
October 02, 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.
« First   ‹ Prev
1 2 3