From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 122957 invoked by alias); 17 Jan 2017 13:24:01 -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 122945 invoked by uid 89); 17 Jan 2017 13:24:00 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 spammy=dog, vegetable, animal, mouse X-HELO: aibo.runbox.com Received: from aibo.runbox.com (HELO aibo.runbox.com) (91.220.196.211) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 17 Jan 2017 13:23:50 +0000 Received: from [10.9.9.210] (helo=mailfront10.runbox.com) by bars.runbox.com with esmtp (Exim 4.71) (envelope-from ) id 1cTTjo-0001L7-2t for kawa@sourceware.org; Tue, 17 Jan 2017 14:23:48 +0100 Received: from 76-9-64-11-rt-broadband-00.broadband.oakhurst.sti.net ([76.9.64.11] helo=localhost.localdomain) by mailfront10.runbox.com with esmtpsa (uid:757155 ) (TLS1.2:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.82) id 1cTTjX-0003wC-9w for kawa@sourceware.org; Tue, 17 Jan 2017 14:23:31 +0100 Subject: Re: behavior of CASE with strings PART 2 To: kawa@sourceware.org References: <201701171107.25991.Damien.Mattei@unice.fr> From: Per Bothner Message-ID: Date: Tue, 17 Jan 2017 13:24:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.6.0 MIME-Version: 1.0 In-Reply-To: <201701171107.25991.Damien.Mattei@unice.fr> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2017-q1/txt/msg00019.txt.bz2 On 01/17/2017 02:07 AM, Damien MATTEI wrote: > testing with eqv? predicate (that seems to be used in kawa CASE if it follow R5RS) and according to https://www.gnu.org/software/kawa/Conditionals.html i have this: > > |kawa:1|# (case "dog" (("cat" "dog" "mouse") "animal") (else "mineral or vegetable")) animal CASE *cannot* meaningfully be used with strings. #|kawa:2|# (case (string-copy "dog") (("cat" "dog" "mouse") "animal") (else "mineral or vegetable")) mineral or vegetable The reason is that case tests use eqv?, and "The eqv? procedure returns #f if" ... "obj 1 and obj 2 are pairs, vectors, bytevectors, records, or strings that denote distinct locations. (quoting directly from R7RS). R5RS is the same in this respect. Thus (eqv? (string-copy "dog") "dog") is #f, as is (eqv? (string #\d #\o #\g) "dog"). Even (eqv? "dog" "dog") is *unspecified* according to R7RS, because it does not require that the two "dog" literals are the same location. It might be reasonable to add a warning, like Kawa does with lists: #|kawa:8|# (case "dog" ((("cat") "dog" "mouse") "animal") (else "mineral or vegetable")) /dev/stdin:8:15: warning - List and vectors will never be matched in a case clause /dev/stdin:8:15: warning - datum type incompatible with the key -- --Per Bothner per@bothner.com http://per.bothner.com/