delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2013/08/03/09:30:17.1

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
From: "Rod Pemberton" <dont_use_email AT nohavenotit DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: _CRT0_FLAG_NULLOK
Date: Sat, 03 Aug 2013 09:17:38 -0400
Organization: Aioe.org NNTP Server
Lines: 51
Message-ID: <op.w08sjo1c0e5s1z@->
References: <21e77579-1a40-4442-8111-fc976fba78fc AT googlegroups DOT com>
<b5o37qFldl9U1 AT mid DOT dfncis DOT de>
<f24e8cd3-83ca-4386-a319-a9adb4d74c68 AT googlegroups DOT com>
<3df2f50f-9543-47a7-8e40-a9be82ce5018 AT googlegroups DOT com>
<87fvuvny2v DOT fsf AT uwakimon DOT sk DOT tsukuba DOT ac DOT jp> <op.w020sren0e5s1z@->
<87ehaeonbp DOT fsf AT uwakimon DOT sk DOT tsukuba DOT ac DOT jp> <op.w04oetou0e5s1z@->
<87zjt1n2v6 DOT fsf AT uwakimon DOT sk DOT tsukuba DOT ac DOT jp>
NNTP-Posting-Host: CNsg4fVcCsvs3UaOgZtQCw.user.speranza.aioe.org
Mime-Version: 1.0
X-Complaints-To: abuse AT aioe DOT org
User-Agent: Opera Mail/12.16 (Linux)
X-Notice: Filtered by postfilter v. 0.8.2
Bytes: 3265
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

On Thu, 01 Aug 2013 06:04:45 -0400, Stephen J. Turnbull  
<turnbull AT sk DOT tsukuba DOT ac DOT jp> wrote:

> Rod Pemberton writes:
>
>  > E.g., [C definition committees] could've specified a NULL pointer
>  > always points to an emtpy string of just a null character.  Such a
>  > specification is unlikely to break C, since a NULL pointer just
>  > needs to have a unique address.  This would've allowed a NULL
>  > pointer to safely function as an empty character string too.
>
> Which is an arbitrary decision,

True.  But, how is that any different than specifying NULL in the
first place?  Specifying that NULL exist to detect valid pointers
is an arbitrary decision too.  This functionality could've been
implemented some other way or simply not at all.

> [...] because it could be a pointer to an
> arbitrary instance of *any* type.

If it's been specified by an arbitrary decision, then the pointer
points to an arbitrary instance of *one* type out of *many*, yes.

No, it wouldn't likely be a pointer to arbitrary instance of some
type other than a char.  That's the only type that would serve
some purpose due to the way strings are implemented in C.
Other types don't have this issue.

> Of course some of those instances
> may be compatible with an empty string, but I don't see how you can
> guarantee they *all* will be, on all machines you might want to target
> with a C compiler.
> [...] So the decision to favor strings is arbitrary.
>

It would only add additional functionality to NULL for use as char
pointers.  AISI, additional functionality for other non-char types
hasn't demonstrated any theoretical or real world need.  Of course,
this apparent need only exists because strings in C are implemented
as arrays instead a complete type.  I.e., they're not "first class
citizens".


Rod Pemberton
-- 
"... to secure these rights, governments are instituted among men,
deriving their just powers from the consent of the governed; that
whenever any form of government becomes destructive of these ends,
it is the right of the people to alter or abolish it ..."
-Thomas Jefferson, Declaration of Independence, 1776

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019