Path: csiph.com!news.fcku.it!news.swapon.de!eternal-september.org!feeder.eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: NULL as the empty string Date: Sat, 09 Dec 2017 11:53:20 -0800 Organization: None to speak of Lines: 29 Message-ID: References: <0f96b837-7b9a-435f-81ec-8bbc8d2f928b@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: reader02.eternal-september.org; posting-host="d19aff521d1f698874161ffa83b5ceb4"; logging-data="27404"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18geOxz9QZDMxYPTAMeGwyS" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:c4lIelpji26P+iBTy3njYqc8/Nc= sha1:W1ImfyxL5xXxr91MHda/vaxRimA= Xref: csiph.com comp.lang.c:124070 jacobnavia writes: > Le 09/12/2017 à 02:47, Keith Thompson a écrit : >> Would it be more convenient to treat a floating-point NaN as equivalent >> to 0.0? [...] > What is your point here? We are talking about strings, not floating > point numbers. I just made a comparison between a representation of > something that is a special value (NAN or inf) and the representation of > the empty string, that could be the NULL pointer. My point is that in floating-point we have a clear and useful distinction between a "null" value, 0.0, and a representation that isn't a numeric value, NaN. For char*, we have a clear distinction between a pointer to an empty string and a pointer that doesn't point to a string at all. They're logically quite distinct, and in my opinion it's a very useful distinction. I concede that it's not a very compelling point. Still, I don't think treating a null pointer as if it were a pointer to an empty string is a good idea. It's not a *horrible* idea, and if it were added to a future standard I'd accept it with a little grumbling. -- Keith Thompson (The_Other_Keith) kst-u@mib.org Working, but not speaking, for JetHead Development, Inc. "We must do something. This is something. Therefore, we must do this." -- Antony Jay and Jonathan Lynn, "Yes Minister"