Message from discussion
Case with strings: normal behavior?
Received: by 10.236.173.130 with SMTP id v2mr9309359yhl.41.1353331108513;
Mon, 19 Nov 2012 05:18:28 -0800 (PST)
X-BeenThere: racket-users@googlegroups.com
Received: by 10.49.51.133 with SMTP id k5ls2320341qeo.74.gmail; Mon, 19 Nov
2012 05:18:28 -0800 (PST)
Received: by 10.58.216.100 with SMTP id op4mr3450386vec.25.1353331108430;
Mon, 19 Nov 2012 05:18:28 -0800 (PST)
Received: by 10.58.216.100 with SMTP id op4mr3450385vec.25.1353331108419;
Mon, 19 Nov 2012 05:18:28 -0800 (PST)
Return-Path: <users-boun...@racket-lang.org>
Received: from champlain.ccs.neu.edu (champlain.ccs.neu.edu. [129.10.115.116])
by gmr-mx.google.com with ESMTPS id dj17si737664vdb.1.2012.11.19.05.18.28
(version=TLSv1/SSLv3 cipher=OTHER);
Mon, 19 Nov 2012 05:18:28 -0800 (PST)
Received-SPF: neutral (google.com: 129.10.115.116 is neither permitted nor denied by domain of users-boun...@racket-lang.org) client-ip=129.10.115.116;
Authentication-Results: gmr-mx.google.com; spf=neutral (google.com: 129.10.115.116 is neither permitted nor denied by domain of users-boun...@racket-lang.org) smtp.mail=users-boun...@racket-lang.org
Received: from champlain.ccs.neu.edu (localhost.localdomain [127.0.0.1])
by champlain.ccs.neu.edu (8.14.4/8.14.4) with ESMTP id qAJDDIJx015598;
Mon, 19 Nov 2012 08:13:20 -0500
Received: from mail-qc0-f174.google.com (mail-qc0-f174.google.com
[209.85.216.174])
by champlain.ccs.neu.edu (8.14.4/8.14.4) with ESMTP id qAJDDB8b015581
for <us...@lists.racket-lang.org>; Mon, 19 Nov 2012 08:13:11 -0500
Received: by mail-qc0-f174.google.com with SMTP id o22so3649786qcr.33
for <us...@lists.racket-lang.org>; Mon, 19 Nov 2012 05:13:10 -0800 (PST)
Received: by 10.224.179.208 with SMTP id br16mr10792174qab.25.1353330790765;
Mon, 19 Nov 2012 05:13:10 -0800 (PST)
MIME-Version: 1.0
Received: by 10.49.16.67 with HTTP; Mon, 19 Nov 2012 05:12:50 -0800 (PST)
In-Reply-To: <CABNTSaGrGSXnC3X=VE62h_g7D9tU3KSFcDN+fdwEJqTTxUvQCg@mail.gmail.com>
References: <CABNTSaGrGSXnC3X=VE62h_g7D9tU3KSFcDN+fdwEJqTTxUvQCg@mail.gmail.com>
From: Sam Tobin-Hochstadt <sa...@ccs.neu.edu>
Date: Mon, 19 Nov 2012 08:12:50 -0500
Message-ID: <CAK=HD+YZGmCnX-pMC9e=D_topBOrx2f8qRy3S89=KFyyFEP...@mail.gmail.com>
To: Laurent <laurent.ors...@gmail.com>
X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00,DKIM_SIGNED,
DKIM_VALID,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW
autolearn=ham version=3.3.1
X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on
champlain.ccs.neu.edu
Cc: Racket Mailing List <us...@lists.racket-lang.org>
Subject: Re: [racket] Case with strings: normal behavior?
X-BeenThere: us...@racket-lang.org
X-Mailman-Version: 2.1.12
Precedence: list
List-Id: Racket Users <users.racket-lang.org>
List-Unsubscribe: <http://lists.racket-lang.org/users/options>,
<mailto:users-requ...@racket-lang.org?subject=unsubscribe>
List-Archive: <http://lists.racket-lang.org/users/archive/>
List-Post: <mailto:us...@racket-lang.org>
List-Help: <mailto:users-requ...@racket-lang.org?subject=help>
List-Subscribe: <http://lists.racket-lang.org/users/listinfo>,
<mailto:users-requ...@racket-lang.org?subject=subscribe>
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Sender: users-boun...@racket-lang.org
Errors-To: users-boun...@racket-lang.org
`case` compares values with `eqv?`, which distinguishes
distinctly-allocated strings with the same contents. Using `match`
instead of `case` will fix the problem.
On Mon, Nov 19, 2012 at 8:07 AM, Laurent <laurent.ors...@gmail.com> wrote:
> Hi,
>
> Is this a bug or a not quite intuitive normal behavior?
>> (define (foo s)
> (case s
> [("a") 'a]
> [else 'none]))
>> (foo "a")
> 'a
>> (foo (string-append "a" ""))
> 'none
>
> in 5.3.1.5--2012-11-08(5589bcb/a) [3m].
>
> Laurent
>
> ____________________
> Racket Users list:
> http://lists.racket-lang.org/users
>
--
sam th
sa...@ccs.neu.edu
____________________
Racket Users list:
http://lists.racket-lang.org/users