NULLs
Hans-Dieter.Dreier@materna.de
Hans-Dieter.Dreier@materna.de
Fri, 16 Jul 1999 17:56:23 +0200
--adrVfTaz1eOAQC0AgbvVMeQgtIR5h8JV
Content-type: text/plain; charset="ISO-8859-1"
Content-transfer-encoding: quoted-printable
(Forwarding a message from jason@injektilo.org)
> Keeping track of possible types is rather easy because the type set =
can be =3D
> easily handled. Keeping track of possible values is hard; so it =
seems sensi=3D
> ble to me to try to map as much as possible of the checking =
sketched above =3D
> to type checking.
> =
I agree. If you're going to support preconditions, you might as well =
let those do the checking for you. I think that it usually won't be =
too obvious what the value of a variable is. Unless, of course, it =
was a constant. Either way, it's a feature that could be optionally =
added to the compiler and not affect the language in any way.
> >I think that it'd be possible to offer a higher-level construct =
for =3D
> =
> >this than checking to see if a pointer equaled NULL, though. Maybe =
a =3D
> =
> >defined keyword? Would this fit with the static type system? Of =3D
> =
> >course, it would probably be implemented by checking to see if the =
=3D
> =
> >reference was set to NULL but we don't need to know that.
> =
> Could you show an example?
> =
void Foo(Bar* pBar)
{
if(valid(pBar))
{
// pBar points to a valid Bar object.
}
}
valid() could be keyword much like sizeof()in C++. The compiler would =
require you check to make sure that a pointer was valid before =
allowing you to use it unless of course you're going to support some =
sort of precondition clauses like eiffel. If a precondition was that =
the pointer had to be valid, then you wouldn't need to check it in =
your function body.
I'm actually starting to like your idea of union types. They might =
come in handy for functions that could possibly work on two disparate =
types. Should it be possible to define a union of types and use that =
union as the type?
For example:
union MyUnion : Foo, Bar, Baz;
void doSomething(MyUnion* xxx)
{
// now you have to do some sort of switch on the type of xxx
}
Should you required that you declare all pointers as a union between =
the type you want and the NULL type or should that be implied?
By the way, did you know that all of your equal ("=3D") signs are being =
translated into "=3D3D" for some strange reason?
Bye,
Jason.
--
Is your email secure? http://www.pop3now.com
(c) 1998,1999 Cave Creations Corp. All rights reserved.
--adrVfTaz1eOAQC0AgbvVMeQgtIR5h8JV
Content-type: text/plain; charset="ISO-8859-1"
Content-transfer-encoding: quoted-printable
IDENTIFIKATIONSANGABEN:
a23781a.txt IA5 DX-MAIL X.400 User Agent=
--adrVfTaz1eOAQC0AgbvVMeQgtIR5h8JV--