Sujet : Re: question about nullptr
De : 643-408-1753 (at) *nospam* kylheku.com (Kaz Kylheku)
Groupes : comp.lang.cDate : 12. Jul 2024, 22:52:47
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <20240712144910.90@kylheku.com>
References : 1 2 3
User-Agent : slrn/pre1.0.4-9 (Linux)
On 2024-07-12, Richard Harnden <
richard.nospam@gmail.invalid> wrote:
On 06/07/2024 13:54, Kaz Kylheku wrote:
On 2024-07-06, Thiago Adams <thiago.adams@gmail.com> wrote:
If you were creating C code today and could use a C23 compiler, would
you use nullptr instead of NULL?
In greenfield projects under my dictatorship, I use 0, as in:
char *p = 0;
I was still 20 something when I (easily) wrapped my head around the 0
null pointer constant, and have not had any problems with it.
Once I learned the standard-defined truth about null pointer constants,
and their relationship to the NULL macro, I dropped NULL like a hot
potato, and didn't look back (except when working in code bases that use
NULL).
>
I don't understand why you wouldn't use NULL.
>
If it's a pointer: NULL
If it's an integer: 0
If it's a double: 0.0
If it's a char: '\0'
>
Don't you use '\n'? Surely nobody would say 0x0a?
But, see, nobody in their right mind would say '\012` for that. '\0'
an octal escape sequence like '\012', not a role-based character
abstraction like '\n'. There is no null character abstraction because
the null character is the concrete zero code.
-- TXR Programming Language: http://nongnu.org/txrCygnal: Cygwin Native Application Library: http://kylheku.com/cygnalMastodon: @Kazinator@mstdn.ca