From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Bastien Newsgroups: gmane.emacs.devel Subject: Re: Why (substring "abc" 0 4) does not return "abc" instead of an error? Date: Mon, 16 Jul 2012 16:40:37 +0200 Organization: GNU Message-ID: <87r4sbeplm.fsf@altern.org> References: <50038E42.1030508@yandex.ru> <87liij3l8f.fsf@kuiper.lan.informatimago.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1342449623 1484 80.91.229.3 (16 Jul 2012 14:40:23 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 16 Jul 2012 14:40:23 +0000 (UTC) Cc: emacs-devel@gnu.org To: "Pascal J. Bourguignon" Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Jul 16 16:40:21 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 1SqmTE-0005CF-En for ged-emacs-devel@m.gmane.org; Mon, 16 Jul 2012 16:40:20 +0200 Original-Received: from localhost ([::1]:49202 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SqmTD-000594-O5 for ged-emacs-devel@m.gmane.org; Mon, 16 Jul 2012 10:40:19 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:48636) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SqmT5-00058Y-Qi for emacs-devel@gnu.org; Mon, 16 Jul 2012 10:40:17 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SqmT0-0007rJ-1H for emacs-devel@gnu.org; Mon, 16 Jul 2012 10:40:11 -0400 Original-Received: from mail-wg0-f49.google.com ([74.125.82.49]:48694) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SqmSz-0007pb-PL for emacs-devel@gnu.org; Mon, 16 Jul 2012 10:40:05 -0400 Original-Received: by wgbez12 with SMTP id ez12so3639400wgb.30 for ; Mon, 16 Jul 2012 07:40:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=sender:from:to:cc:subject:in-reply-to:organization:references :user-agent:date:message-id:mime-version:content-type; bh=EEbEQTZFJGKcZjettLUPHNfnKYaN+8zHwWUKfmmtqus=; b=ixVh4Mim1vaRkQZhCDzX0vGZn0yqb1XpDWOkdKHTtUcgEd9g7i8aUH9iWS7fOvZ3cM OCFgx9X7LZ4YC4tILnQwUn+/CtvfcPxNm9+AEAKZzAugj0WK8Lf37np7l9BxiQCGMlOV xaOILRHmMiIQHMIBnr6hoqzxUHQrywV2QnYbE5ETKgmJPk8tXu9G/GRkSKi1lUEKqA+C 35ZzAA3EtQ7SCEEWGjagq3SeudEmWVC9IdA9gZLdNblbNaEY10Vb4yOazFKZ1n44nDiK yDTQ8DIo0HWTeKANIjO2Zs4IBIeJqkyWaD3M8mbJ+kCjuqLOSl+fXNmCU81hxcCgNwP+ xS/w== Original-Received: by 10.216.80.85 with SMTP id j63mr6146100wee.211.1342449604762; Mon, 16 Jul 2012 07:40:04 -0700 (PDT) Original-Received: from myhost.localdomain (mar75-2-81-56-68-112.fbx.proxad.net. [81.56.68.112]) by mx.google.com with ESMTPS id cu1sm21818945wib.6.2012.07.16.07.40.03 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 16 Jul 2012 07:40:03 -0700 (PDT) Original-Received: by myhost.localdomain (Postfix, from userid 1000) id 0AB7D8207; Mon, 16 Jul 2012 16:40:37 +0200 (CEST) In-Reply-To: <87liij3l8f.fsf@kuiper.lan.informatimago.com> (Pascal J. Bourguignon's message of "Mon, 16 Jul 2012 15:10:24 +0200") User-Agent: Gnus/5.130006 (Ma Gnus v0.6) Emacs/24.1.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 74.125.82.49 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:151667 Archived-At: Hi Pascal, "Pascal J. Bourguignon" writes: > (defun mysubstring (str start end) > (substring str (max start 0) > (if end > (min end (length str)) > (length str)))) > > and use (mysubstring "abc" 0 4) --> "abc" > instead of substring. I know how to implement my own defun for this but thanks. My question was about what _justifies_ the current behavior. Dmitry said at least JS, Ruby, Python and perhaps C++ uses the behavior I mention -- so I'm even more curious now. I am not saying the behavior I expect is superior, it is just the one I expect -- I would like to read a good reason for the current one. Juanma have a point when he said that the current behavior is consistent with other *-substring functions but again, `substring' seems different to me. > The point of lisp is to let you define your own language seamlessly. True. But the point of sharing code is also to not reinvent the wheel, right? Best, -- Bastien