ExternalInteger | isNull test incorrect?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

ExternalInteger | isNull test incorrect?

Eric Winger-4
I've been experimenting a bit with passing COM null pointers in via
SDWORD* & DWORD* parameter types and have found that this test seems to
be wrong.

ExternalInteger | isNull
        "Answer whether the receiver is Null (i.e. equal to 0).
        This message is useful way of testing for NULL pointers or handles."

        ^self value == 0


The problem is that if the external integer is indeed a null pointer,
then this will die a mean, nasty horrible death.

A better test, IMHO, would be:

ExternalInteger | isNull
       
        ^self bytes isNull

I believe that this will work more reliably than the other test.

Agree/Disagree?

Eric


Reply | Threaded
Open this post in threaded view
|

Re: ExternalInteger | isNull test incorrect?

Blair McGlashan
Eric

You wrote in message news:[hidden email]...

> I've been experimenting a bit with passing COM null pointers in via
> SDWORD* & DWORD* parameter types and have found that this test seems to
> be wrong.
>
> ExternalInteger | isNull
> "Answer whether the receiver is Null (i.e. equal to 0).
> This message is useful way of testing for NULL pointers or handles."
>
> ^self value == 0
>
>
> The problem is that if the external integer is indeed a null pointer,
> then this will die a mean, nasty horrible death.
>
> A better test, IMHO, would be:
>
> ExternalInteger | isNull
>
> ^self bytes isNull
>
> I believe that this will work more reliably than the other test.
>
> Agree/Disagree?

Up to a point - although it fixes one problem it causes another. In Dolphin
5.0 the implementation is as follows:

isNull

    "Answer whether the receiver is Null (i.e. equal to 0).

    This message is useful way of testing for NULL pointers or handles."

    ^super isNull or: [self value == 0]

The superclass definition is (essentially) '^bytes isNull'. This result is
an implementation that answers true if the pointer is null or the value is
null.

Regards

Blair