January 25, 2013 Re: Why is null lowercase? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ali Çehreli | On Friday, 25 January 2013 at 01:17:44 UTC, Ali Çehreli wrote:
> On 01/24/2013 12:42 PM, Matthew Caron wrote:
>
> >> for not null checks
> >>
> >> if ( ptr !is null) ...
> >
> > And too much perl has me wanting to write:
> >
> > if (ptr is not null)
>
> IIRC, the !is operator is thanks to bearophile.
No, it's from 2002 (well, it was !==, renamed to !is in 2005).
Bearophile only joined us about the time D2 began, in late 2007.
|
January 25, 2013 Re: Why is null lowercase? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Don | On 01/25/2013 06:22 AM, Don wrote: >> IIRC, the !is operator is thanks to bearophile. > > No, it's from 2002 (well, it was !==, renamed to !is in 2005). > Bearophile only joined us about the time D2 began, in late 2007. Ok. How about !in then? Did he lobby for that one? :) Ali |
January 25, 2013 Re: Why is null lowercase? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Don | On Friday, 25 January 2013 at 14:22:20 UTC, Don wrote:
> On Friday, 25 January 2013 at 01:17:44 UTC, Ali Çehreli wrote:
>> On 01/24/2013 12:42 PM, Matthew Caron wrote:
>>
>> >> for not null checks
>> >>
>> >> if ( ptr !is null) ...
>> >
>> > And too much perl has me wanting to write:
>> >
>> > if (ptr is not null)
>>
>> IIRC, the !is operator is thanks to bearophile.
>
> No, it's from 2002 (well, it was !==, renamed to !is in 2005).
> Bearophile only joined us about the time D2 began, in late 2007.
It would be nice a to have a wiki page about D history written by old-timers.
|
January 25, 2013 Re: Why is null lowercase? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ali Çehreli | On Friday, 25 January 2013 at 14:43:01 UTC, Ali Çehreli wrote:
> On 01/25/2013 06:22 AM, Don wrote:
>> No, it's from 2002 (well, it was !==, renamed to !is in 2005). Bearophile only joined us about the time D2 began, in late 2007.
>
> Ok. How about !in then? Did he lobby for that one? :)
//hmmm doesn't read right
if (ptr in not null)
//huh? is it an array or an AA now?
if (ptr not in null)
//ummm feels like an AA. I'm sure if we used
//it it would become second nature.
if (ptr !in null)
//silently converts to...?
if (!(ptr in null))
//make sense to me. Course in java === was
//used for ptr checking rather than contents.
if (ptr === null) //is null
if (ptr !== null) //not null, both stand out
//mentally I reverse !is to equal 'is not'.
//I know I'm comparing pointers.
if (ptr !is null)
Code example:
string[string] aa;
string* ptr;
if ("dog" in aa) //returns ptr
if ("dog" !in aa) //i think it's bool of 'found'
ptr = "dog" in aa;
if (ptr in null) //errors, not an aa, searching null?
if (ptr !in null) //not searching null?
change to...
string[string[string]] aa;
string[string]* ptr; //(string[string])* ptr; ??
if ("dog" in aa) //returns ptr (of an aa), search
if ("dog" !in aa) //still makes sense... a search.
ptr = "dog" in aa;
if (ptr in null) //becomes ((*ptr) in aa), search?
//(!((*ptr) in null))//AA search or pointer compare?
if (ptr !in null)
null can still be replaced by any variable/pointer, if that pointer is an aa as well... Ugg I don't wanna find out all the combinations to figure it out...
After looking at all these 'in' should be reserved for array searching, not pointer checking. It makes more sense to me that way.
|
January 25, 2013 Re: Why is null lowercase? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Era Scarecrow | On 01/25/2013 10:31 AM, Era Scarecrow wrote: > On Friday, 25 January 2013 at 14:43:01 UTC, Ali Çehreli wrote: >> On 01/25/2013 06:22 AM, Don wrote: >>> No, it's from 2002 (well, it was !==, renamed to !is in 2005). >>> Bearophile only joined us about the time D2 began, in late 2007. >> >> Ok. How about !in then? Did he lobby for that one? :) > //ummm feels like an AA. I'm sure if we used > //it it would become second nature. > if (ptr !in null) Isn't that an error to apply the in operator to null? The expression above is syntactic sugar for the following one: !null.opBinaryRight!"in"(ptr)) Yes, there is also opBinary!"in" but it doesn't make sense to me to put the container on the left-hand side ever: if (myContainer in myElement) Doesn't make sense. > After looking at all these 'in' should be reserved for array searching, > not pointer checking. It makes more sense to me that way. Sorry if I implied otherwise. Yes, 'in' should be for that purpose. I merely tried to remember what syntax has been bearophile's strong suggestion. ;) Ali |
January 25, 2013 Re: Why is null lowercase? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ali Çehreli | On Friday, 25 January 2013 at 18:57:06 UTC, Ali Çehreli wrote:
> On 01/25/2013 10:31 AM, Era Scarecrow wrote:
>> After looking at all these 'in' should be reserved for array searching, not pointer checking. It makes more sense to me that way.
>
> Sorry if I implied otherwise. Yes, 'in' should be for that purpose. I merely tried to remember what syntax has been bearophile's strong suggestion. ;)
Not so much implied as considered. Had it been used, it would be obvious there was problems with it, both with meanings and added ambiguities.
Oh well. One thing at a time..
|
January 27, 2013 Re: Why is null lowercase? | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile | > DO YOU PREFER A LANGUAGE ALL IN UPPERCASE?
>
Hahahaha! I find it ugly too. I prefer lowercaps null, as in Java.
|
January 27, 2013 Re: Why is null lowercase? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Maxim Fomin | On Friday, 25 January 2013 at 16:11:57 UTC, Maxim Fomin wrote:
> On Friday, 25 January 2013 at 14:22:20 UTC, Don wrote:
>> On Friday, 25 January 2013 at 01:17:44 UTC, Ali Çehreli wrote:
>>> On 01/24/2013 12:42 PM, Matthew Caron wrote:
>>>
>>> >> for not null checks
>>> >>
>>> >> if ( ptr !is null) ...
>>> >
>>> > And too much perl has me wanting to write:
>>> >
>>> > if (ptr is not null)
>>>
>>> IIRC, the !is operator is thanks to bearophile.
>>
>> No, it's from 2002 (well, it was !==, renamed to !is in 2005).
>> Bearophile only joined us about the time D2 began, in late 2007.
>
> It would be nice a to have a wiki page about D history written by old-timers.
I vote for that too!
|
Copyright © 1999-2021 by the D Language Foundation