NULLs

Hans-Dieter.Dreier@materna.de Hans-Dieter.Dreier@materna.de
Fri, 16 Jul 1999 17:54:32 +0200


--pphy9bOpz9PSoBb7qCJwLeMO5ELzkUQP
Content-type: text/plain; charset="ISO-8859-1"
Content-transfer-encoding: quoted-printable

(Forwarding a message from jason@injektilo.org):




Hi. I've been lurking for a while. Thought I'd add my $0.02 for a =

change.

>
> NULLs are very convenient but they also introduce some problems:
> =

> 1. They do not fit nicely into a statical type system.

Is this because you can assign NULL to any variable regardless of its =

type? Is this really that bad?

> =

> A, B: aUnion			// object named aUnion may be an A or =

a B
> =

> .... to be used like this:
> =

> if aUnion.classOf =3D3D=3D3D A // classOf is allowed for any object
>   then <do something> // here compiler knows aUnion is an A
>   else <do something else> // here compiler knows it is something =

else, in =3D
> this case it must be a B
> =

> IOW, you cannot use aUnion as an A unless you make sure (by a =

contional) it=3D
>  really *is* an A.

How is this different than checking to see if the variable in =

question is set to NULL?

You might actually be on to something. Some programmers claim that =

one should always check every pointer passed or returned to them as =

if they could possibly be NULL. This is unarguably a good programming =

practice. What if a language required that you check each pointer for =

NULL before you could use it in a function or after a function call? =

If the result of a function could never be NULL, then you could =

return a reference in which case the compiler wouldn't require you to =

check to see if it's NULL.

I think that it'd be possible to offer a higher-level construct for =

this than checking to see if a pointer equaled NULL, though. Maybe a =

defined keyword? Would this fit with the static type system? Of =

course, it would probably be implemented by checking to see if the =

reference was set to NULL but we don't need to know that.

Jason Diamond.



--
Is your email secure? http://www.pop3now.com
(c) 1998,1999 Cave Creations Corp. All rights reserved.

--pphy9bOpz9PSoBb7qCJwLeMO5ELzkUQP
Content-type: text/plain; charset="ISO-8859-1"
Content-transfer-encoding: quoted-printable

IDENTIFIKATIONSANGABEN:
a23670a.txt IA5 DX-MAIL X.400 User Agent=

--pphy9bOpz9PSoBb7qCJwLeMO5ELzkUQP--