From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Thien-Thi Nguyen Newsgroups: gmane.emacs.devel Subject: Re: Why (substring "abc" 0 4) does not return "abc" instead of an error? Date: Mon, 16 Jul 2012 21:49:17 +0200 Message-ID: <87zk6z8p1e.fsf@zigzag.favinet> References: <50038E42.1030508@yandex.ru> <87liij3l8f.fsf@kuiper.lan.informatimago.com> <87r4sbeplm.fsf@altern.org> <87hat73g4l.fsf@kuiper.lan.informatimago.com> <87ehobd7zi.fsf@gnu.org> <87629nd7tu.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1342468160 29499 80.91.229.3 (16 Jul 2012 19:49:20 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 16 Jul 2012 19:49:20 +0000 (UTC) Cc: "Pascal J. Bourguignon" , emacs-devel@gnu.org To: Bastien Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Jul 16 21:49:20 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 1SqrIF-0001g1-GB for ged-emacs-devel@m.gmane.org; Mon, 16 Jul 2012 21:49:19 +0200 Original-Received: from localhost ([::1]:54800 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SqrIE-0003ah-SK for ged-emacs-devel@m.gmane.org; Mon, 16 Jul 2012 15:49:18 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:47956) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SqrIB-0003aR-Pf for emacs-devel@gnu.org; Mon, 16 Jul 2012 15:49:16 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SqrIA-0002Xg-RP for emacs-devel@gnu.org; Mon, 16 Jul 2012 15:49:15 -0400 Original-Received: from smtp206.alice.it ([82.57.200.102]:53124) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SqrI9-0002WM-5Y; Mon, 16 Jul 2012 15:49:13 -0400 Original-Received: from zigzag.favinet (80.180.3.208) by smtp206.alice.it (8.6.023.02) id 4FFCD56E00F63602; Mon, 16 Jul 2012 21:49:11 +0200 Original-Received: from ttn by zigzag.favinet with local (Exim 4.72) (envelope-from ) id 1SqrID-0001FR-P6; Mon, 16 Jul 2012 21:49:17 +0200 In-Reply-To: <87629nd7tu.fsf@gnu.org> (Bastien's message of "Mon, 16 Jul 2012 17:49:49 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.1 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 82.57.200.102 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:151689 Archived-At: () Bastien () Mon, 16 Jul 2012 17:49:49 +0200 Bastien writes: > I'm not interested in doing crazy stuff, I'm interested in > > (substring "abc" 0 4 t) > =3D> "abc" > > where `t' is the value of an option third NOERROR argument. ^^^^^ Fourth, actually. If you prefer this slackful =E2=80=98substring=E2=80=99 and would like to u= se it everywhere, then in practice "extending" =E2=80=98substring=E2=80=99 has th= e same cost as writing a personalized version. How's that? Imagine if =E2=80=98substring=E2=80=99 were to indeed be changed to support= this NOERROR argument. Since you want to use it everywhere, you would start converting all the callsites to include NOERROR =E2=80=98t=E2=80=99. = After a bit, you'd look askance at this extra verbosity, and decide to abstract it w/ a personalized function, say "subs". (defun subs (string beg end) (substring string beg end t)) "Ah, much better!" you think. Well i would agree. But now that you have =E2=80=98subs=E2=80=99 (and use it everywhere), why precisely do y= ou need the extended =E2=80=98substring=E2=80=99 anymore? You could have saved the= effort of going north 1 then east 1 by going northeast 1.414... (defun subs (string beg end) (substring string beg (and (< end (length string)) end))) ...in the first place. Overall, the design principle is that you want the platform to be firm and the performer flexible, not the other way around. The audience may be pleased either way, but as producer, you want the roadies to sleep better lest they revolt...