Path: csiph.com!usenet.pasdenom.info!aioe.org!.POSTED!not-for-mail From: "Rod Pemberton" Newsgroups: comp.lang.forth Subject: Re: CASE mis-understanding? Date: Thu, 27 Feb 2014 16:23:50 -0500 Organization: Aioe.org NNTP Server Lines: 42 Message-ID: References: <52e54d17.461102185@news.demon.co.uk> <85ha7kg45j.fsf@junk.nocrew.org> <4P6dnWTTv7tKspLOnZ2dnUVZ_sGdnZ2d@supernews.com> <7xlhwwela4.fsf@ruckus.brouhaha.com> <530f5e60$0$25041$e4fe514c@dreader37.news.xs4all.nl> NNTP-Posting-Host: CNsg4fVcCsvs3UaOgZtQCw.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: Opera Mail/12.16 (Linux) X-Notice: Filtered by postfilter v. 0.8.2 Xref: csiph.com comp.lang.forth:28820 On Thu, 27 Feb 2014 10:48:48 -0500, Albert van der Horst wrote: > In article <7xlhwwela4.fsf@ruckus.brouhaha.com>, > Paul Rubin wrote: >> Andrew Haley writes: >>> How is that semantically different from a null pointer? Surely NIL is >>> a null pointer, however it is represented. >> >> Each list node is a discriminated union (member of a sum type) that's >> either NIL, or a pair consisting of a value and a pointer to the next >> node. So in the case where it's NIL, that's not a pointer. With a >> static type system, if the list has a type like List, the NIL for >> that list would also have that type, and any attempt to dereference it >> would be caught at compile time. > > So instead of a runtime system that gives an error: > "attempt to derefence a nil pointer" the user is obliged to put > some code in to give that error himself. Big advantage -;) > > Really, on paper and properly implemented, the null pointer in C is > a fairly decent nil value. Properly implemented in my book means > that an access through the pointer must be trapped. > AFAIK, there's no requirement in C to prevent reading or writing to the same address as the NULL pointer. AFAIK, there is no requirement to trap accesses to it's location either. The requirement is that no C objects must be located *at* the NULL pointer address. The NULL is for comparing a pointer in C against NULL to determine if the pointer was set or not. I know for a fact that many C compilers implement NULL as zero and also allow reading and writing to address zero via a C pointer. The NULL pointer's address is zero for many C implementations, but can be any location as long as no other C objects are located at that address, i.e., NULL can be non-zero. One of the original authors of the ANSI C specification posted an example of how to do that many years ago. C compilers which allow writing to the same address as NULL is usually because the NULL pointer value is zero *and* there is memory mapped device or data space located there that must be accessable. Rod Pemberton