Topic: NULL definition
Author: David R Tribble <david@tribble.com>
Date: 1999/10/30 Raw View
Ron Natalie wrote:
>=20
> St=E9phane Tirard wrote:
>> I heard that the NULL pointer was now obsolete because of
>> no-portability.
>> Is is true and which system do not support it ?
>=20
> If every implementation played to the standard, NULL would be OK.
>=20
> The problems is that years ago, certain whiners allowed C to allow
> for the definition of NULL to be defined with a (void*) cast. Of
> course, this annoys C++ because there is no implicit conversion
> of void* to another pointer type. Since C++ played stepchild to
> a bunch of existing C include files on most implementations, the
> conventional wisdom was to just use 0 for your null pointer constant.
When NULL is defined as ((void*)0) in C, it works amazingly well,
and has the simple advantage that it makes code using it a little
easier to read and maintain. Such a definition is also not embued
with a non-pointer type.
C++ has tighter type-checking semnatics, so ((void*)0) doesn't
work as a null pointer constant right out of the box. Thus, C++
was forced to go back to defining NULL as 0 only. Which leads to
annoying ambiguities, and tends to lead some programmers into simply
use integer 0 instead of the more informative NULL, which leads to
annoyed maintenance programmers.
As I and others have pointed out many times in comp.std.c++, it would
have been rather trivial for ISO to have allowed ((void*)0) as a
special case of "untyped null pointer constant". Alas.
> Frankly, I've never been a big fan of NULL (and was not fond of the
> sloppy reason why C allows the cast in the constant).
Then it's a given that I will find your code ugly. FWIW, the C
rules make for a cleaner and more consistent NULL; it's the C++
rules for NULL that are sloppy.
I've come to the conclusion that the proponents of "0 as null" just
don't understand why we opponents find it so ugly and why we would
rather use 'NULL' or 'null'.
-- David R. Tribble, david@tribble.com, http://www.david.tribble.com --
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: Ron Natalie <ron@sensor.com>
Date: 1999/10/22 Raw View
St=E9phane Tirard wrote:
>=20
> Hello,
>=20
> I heard that the NULL pointer was now obsolete because of
> no-portability.
> Is is true and which system do not support it ?
If every implementation played to the standard, NULL would be OK.
The problems is that years ago, certain whiners allowed C to allow
for the definition of NULL to be defined with a (void*) cast. Of
course, this annoys C++ because there is no implicit conversion
of void* to another pointer type. Since C++ played stepchild to
a bunch of existing C include files on most implementations, the
conventional wisdom was to just use 0 for your null pointer constant.
Frankly, I've never been a big fan of NULL (and was not fond of the
sloppy reason why C allows the cast in the constant).
-Ron
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: comeau@panix.com (Greg Comeau)
Date: 1999/10/22 Raw View
In article <380BA934.72BC6CB9@wanadoo.fr> =?iso-8859-1?Q?St=E9phane?= Tirard <s.tirard@wanadoo.fr> writes:
>Hello,
>
>I heard that the NULL pointer was now obsolete because of
>no-portability.
>Is is true and which system do not support it ?
Well, there is NULL and `null pointer' so I'm not sure what
you mean exactly when you mention `NULL pointer', but in any event,
all permutations :) are alive and well. If this is not what
you mean then you'll need to be more specific.
- Greg
--
Comeau Computing, 91-34 120th Street, Richmond Hill, NY, 11418-3214
Producers of Comeau C/C++ 4.2.38 -- NOTE 4.2.42 BETAS NOW AVAILABLE
Email: comeau@comeaucomputing.com / Voice:718-945-0009 / Fax:718-441-2310
*** WEB: http://www.comeaucomputing.com ***
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: clamage@eng.sun.com (Steve Clamage)
Date: 1999/10/22 Raw View
=?iso-8859-1?Q?St=E9phane?= Tirard <s.tirard@wanadoo.fr> writes:
>I heard that the NULL pointer was now obsolete because of
>no-portability.
Your statement is not well-formed, but I can't think of any
interpretation of it that would be true.
NULL is the name of a macro defined in several standard C++
headers. It evaluates to a null pointer constant. NULL is
not obsolete, or even deprecated. Every C++ implementation
must supply the macro in the designated headers.
The terms "null pointer" and "null pointer constant" are
fundamental in C++. A null pointer is one which points
to no object or function. You can indicate a null pointer
in source code by writing a null pointer constant (such as
0 or NULL) in a pointer context. Every C++ implementation
must support that.
--
Steve Clamage, stephen.clamage@sun.com
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: =?iso-8859-1?Q?St=E9phane?= Tirard <s.tirard@wanadoo.fr>
Date: 1999/10/21 Raw View
Hello,
I heard that the NULL pointer was now obsolete because of
no-portability.
Is is true and which system do not support it ?
Thanks
St=E9phane
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]