Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Kaz Kylheku <643-408-1753@kylheku.com> Newsgroups: comp.lang.c Subject: Re: question about nullptr Date: Fri, 12 Jul 2024 21:52:47 -0000 (UTC) Organization: A noiseless patient Spider Lines: 36 Message-ID: <20240712144910.90@kylheku.com> References: <20240706054641.175@kylheku.com> Injection-Date: Fri, 12 Jul 2024 23:52:47 +0200 (CEST) Injection-Info: dont-email.me; posting-host="ce9d7750f6a622c8d90995dce7832ee4"; logging-data="3377762"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+yUEW/v5JWvbU1jJPq2jcyUePCuYt/8oE=" User-Agent: slrn/pre1.0.4-9 (Linux) Cancel-Lock: sha1:SXP9pw2Q34MpIQBzbvWOMvQ2MxU= Bytes: 2277 On 2024-07-12, Richard Harnden wrote: > On 06/07/2024 13:54, Kaz Kylheku wrote: >> On 2024-07-06, Thiago Adams 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/txr Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal Mastodon: @Kazinator@mstdn.ca