May 12, 2004
On Wed, 12 May 2004 13:29:02 +1000, James McComb wrote:

> 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.IsNull
> 
> This 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

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 PM
May 12, 2004
James McComb wrote:
>>This IsNull property idea intrigues me (no foolin', this time).
>>But it should probably be isNull, rather than IsNull.> 

Derek Parnell 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.

Thanks for this explanation.

OK, so it's not worth introducing an isNull property.

James McComb
May 12, 2004
James McComb wrote:

> 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

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/
May 22, 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> 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.



1 2 3 4
Next ›   Last »