From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Andreas Schwab Newsgroups: gmane.emacs.devel Subject: Re: Why (substring "abc" 0 4) does not return "abc" instead of an error? Date: Mon, 16 Jul 2012 09:38:47 +0200 Message-ID: References: <87fw8smxag.fsf@gnu.org> <877gu4mv85.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1342424340 23744 80.91.229.3 (16 Jul 2012 07:39:00 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 16 Jul 2012 07:39:00 +0000 (UTC) Cc: Bastien , emacs-devel@gnu.org To: Juanma Barranquero Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Jul 16 09:39:00 2012 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1SqftU-0007HA-3A for ged-emacs-devel@m.gmane.org; Mon, 16 Jul 2012 09:39:00 +0200 Original-Received: from localhost ([::1]:40548 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SqftT-0005rh-DI for ged-emacs-devel@m.gmane.org; Mon, 16 Jul 2012 03:38:59 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:51730) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SqftR-0005rK-Fe for emacs-devel@gnu.org; Mon, 16 Jul 2012 03:38:58 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SqftL-0003SM-Rk for emacs-devel@gnu.org; Mon, 16 Jul 2012 03:38:57 -0400 Original-Received: from mail-out.m-online.net ([212.18.0.9]:51911) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SqftK-0003Rd-HX; Mon, 16 Jul 2012 03:38:50 -0400 Original-Received: from frontend4.mail.m-online.net (unknown [192.168.8.180]) by mail-out.m-online.net (Postfix) with ESMTP id 3WbGk11qC2z4KKG4; Mon, 16 Jul 2012 09:40:09 +0200 (CEST) Original-Received: from igel.home (ppp-88-217-97-255.dynamic.mnet-online.de [88.217.97.255]) by mail.mnet-online.de (Postfix) with ESMTPA id 3WbGhS6VSjzbbgn; Mon, 16 Jul 2012 09:38:48 +0200 (CEST) Original-Received: by igel.home (Postfix, from userid 501) id 5FAFECA2A3; Mon, 16 Jul 2012 09:38:48 +0200 (CEST) X-Yow: Somewhere in suburban Honolulu, an unemployed bellhop is whipping up a batch of illegal psilocybin chop suey!! In-Reply-To: (Juanma Barranquero's message of "Mon, 16 Jul 2012 02:10:37 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.1 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-Received-From: 212.18.0.9 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:151655 Archived-At: Juanma Barranquero writes: > BTW, for unexpected behavior wrt strings, my favourite is this one > (it's not a bug); > > (let ((s "ab") (m 2)) (eq (substring s 0 m) (substring s 0 m))) => nil > (let ((s "ab") (m 1)) (eq (substring s 0 m) (substring s 0 m))) => nil > (let ((s "ab") (m 0)) (eq (substring s 0 m) (substring s 0 m))) => t That's not much different from ("foo" == "foo") in C. Using eq for comparing non-atoms is seldom useful. Andreas. -- Andreas Schwab, schwab@linux-m68k.org GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different."