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:43 -0500 Organization: Aioe.org NNTP Server Lines: 37 Message-ID: References: <52e54d17.461102185@news.demon.co.uk> <7xppmks7v9.fsf@ruckus.brouhaha.com> <2014Feb18.181426@mips.complang.tuwien.ac.at> <7xmwhoi4px.fsf@ruckus.brouhaha.com> <7xeh2yi77o.fsf@ruckus.brouhaha.com> <7xlhx2rckq.fsf@ruckus.brouhaha.com> <7xy51275wq.fsf@ruckus.brouhaha.com> <7xsir9hwbh.fsf@ruckus.brouhaha.com> <2014Feb24.183059@mips.complang.tuwien.ac.at> <7x38j8rva9.fsf@ruckus.brouhaha.com> <2014Feb26.135958@mips.complang.tuwien.ac.at> <7xeh2pjisl.fsf@ruckus.brouhaha.com> <85ha7kg45j.fsf@junk.nocrew.org> <4P6dnWTTv7tKspLOnZ2dnUVZ_sGdnZ2d@supernews.com> 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:28819 On Thu, 27 Feb 2014 13:12:54 -0500, Elizabeth D. Rather wrote: > On 2/27/14 2:30 AM, Andrew Haley wrote: >> Lars Brinkhoff wrote: >>> Andrew Haley writes: >>>>> These days the very existence of null pointers should be seen as a >>>>> language wart. >>>> >>>> Umm, how would you represent the end of a linked list? >>> >>> By pointing to a dedicated end-of-list object. E.g. in Lisp, lists >>> are terminated with NIL (which in some implementations cleverly >>> doubles as both a cons cell and a symbol). >> >> How is that semantically different from a null pointer? Surely NIL is >> a null pointer, however it is represented. > > Fortunately, Forth is not C. A zero is the perfect end to a linked list, > lending itself to fast, simple loops of the form, > > BEGIN LINK @ WHILE ... > Most C compilers use a value of zero for their NULL pointer, but they're *not* required to do so. C can have a non-zero value for NULL. The only requirement for NULL is it's address doesn't match the address of a valid C object. I.e., NULL is being used as a sentinel value or magic number. One of the original C89 authors provided a simplified example of how to implement a non-zero NULL, many years ago. Unfortunately, a non-zero NULL is a major source of confusion for those new to C and even many "experts" in C, since C's syntax usually allows for '0' and 'NULL' to be used interchangeably. However, a C compiler will use the correct one for the data type, i.e., '0' for integers, and 'NULL' for pointers. Rod Pemberton