From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20128 invoked by alias); 1 Jul 2013 06:20:35 -0000 Mailing-List: contact kawa-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: kawa-owner@sourceware.org Received: (qmail 20054 invoked by uid 89); 1 Jul 2013 06:20:34 -0000 X-Spam-SWARE-Status: No, score=-3.1 required=5.0 tests=AWL,BAYES_00,KHOP_THREADED,RCVD_IN_DNSWL_LOW,RCVD_IN_HOSTKARMA_NO,RCVD_IN_HOSTKARMA_YE,SPF_PASS autolearn=ham version=3.3.1 Received: from aibo.runbox.com (HELO aibo.runbox.com) (91.220.196.211) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Mon, 01 Jul 2013 06:20:33 +0000 Received: from [10.9.9.206] (helo=mailfront02.runbox.com) by bars.runbox.com with esmtp (Exim 4.71) (envelope-from ) id 1UtXTS-00089D-SU; Mon, 01 Jul 2013 08:20:30 +0200 Received: from adsl-216-102-199-253.dsl.snfc21.pacbell.net ([216.102.199.253] helo=localhost.localdomain) by mailfront02.runbox.com with esmtpsa (uid:757155 ) (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.76) id 1UtXTL-0006sE-OX; Mon, 01 Jul 2013 08:20:24 +0200 Message-ID: <51D11FA3.6080108@bothner.com> Date: Mon, 01 Jul 2013 06:20:00 -0000 From: Per Bothner User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130625 Thunderbird/17.0.7 MIME-Version: 1.0 To: Matthieu Vachon CC: "kawa@sourceware.org" Subject: Re: proposed changes to handling of false and end-of-list References: <51CE82FC.9090209@bothner.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-SW-Source: 2013-q3/txt/msg00001.txt.bz2 On 06/30/2013 08:09 PM, Matthieu Vachon wrote: > On Sat, Jun 29, 2013 at 2:47 AM, Per Bothner wrote: >> A linked-list may be >> terminated by either '() (i.e. LList.Empty) or Java null. Lists >> constructed using the Scheme reader or the 'list' function would >> by terminated by LList.Empty as now. > > I'm less sure about this change, how would this work. If I understand > correctly, writing `(1 2 3)` or `(list 1 2 3)` would have a '() as the last > element. Not the "last element" - the "tail". The last element is 3. The last (i.e. 3rd) cons cell (pair) has 3 as the value of its car and '() (i.e. LList.Empty) as the value of its cdr. > For the null part, I would I create such list. Something like > this `(list 1 2 3 #!null)` would not end with a '() but rather a #!null ? You're confusing car and cdr. `(1 2 3 #!null)` is a 4-element list, whose last (i.e. 4th) cons cell (pair) has #!null as the value of its car and '() (i.e. LList.Empty) as the value of its cdr. However, `(1 2 3 . #!null)` (note the dot) is a 3-element list last (i.e. 3rd) cons cell (pair) has 3 as the value of its car and #!null as the value of its cdr. `(1 2 3 . ())` is in all respects equivalent to `(1 2 3)`. However, `(1 2 3 . ())` and `(1 2 3 . #!null)` are the same *when viewed as a list*, however they would not be equal? They're not equal? because as explained in the "Equality" section here: http://www.gnu.org/software/guile/manual/html_node/Nil.html However, most functions that work on lists, such as length and map, would treat `(1 2 3 . ())` and `(1 2 3 . #!null)` the same. > This seems reasonable. But I'm unsure of all the implications > for this change on my existing code base. Do you think this change > would be fully backward compatible? No, it will not. Most obviously: (if #!null 't 'f) would return 'f where it currently returns 't. Even if you don't use #!null explicitly, it will show up if you call a Java method that returns null. -- --Per Bothner per@bothner.com http://per.bothner.com/