From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Pascal J. Bourguignon" Newsgroups: gmane.emacs.devel Subject: Re: Why (substring "abc" 0 4) does not return "abc" instead of an error? Date: Mon, 16 Jul 2012 17:19:11 +0200 Organization: Informatimago Message-ID: <87y5mju428.fsf@kuiper.lan.informatimago.com> References: <50038E42.1030508@yandex.ru> <87liij3l8f.fsf@kuiper.lan.informatimago.com> <87r4sbeplm.fsf@altern.org> <87hat73g4l.fsf@kuiper.lan.informatimago.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1342451982 22408 80.91.229.3 (16 Jul 2012 15:19:42 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 16 Jul 2012 15:19:42 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Jul 16 17:19:41 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 1Sqn5I-0005kH-Gu for ged-emacs-devel@m.gmane.org; Mon, 16 Jul 2012 17:19:40 +0200 Original-Received: from localhost ([::1]:46375 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sqn5H-0004uV-QR for ged-emacs-devel@m.gmane.org; Mon, 16 Jul 2012 11:19:39 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:57527) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sqn5E-0004ts-RL for emacs-devel@gnu.org; Mon, 16 Jul 2012 11:19:37 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Sqn58-0003Sl-U2 for emacs-devel@gnu.org; Mon, 16 Jul 2012 11:19:36 -0400 Original-Received: from plane.gmane.org ([80.91.229.3]:48615) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sqn58-0003SQ-Mu for emacs-devel@gnu.org; Mon, 16 Jul 2012 11:19:30 -0400 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1Sqn54-0005WD-1s for emacs-devel@gnu.org; Mon, 16 Jul 2012 17:19:26 +0200 Original-Received: from 81.202.16.46.dyn.user.ono.com ([81.202.16.46]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 16 Jul 2012 17:19:26 +0200 Original-Received: from pjb by 81.202.16.46.dyn.user.ono.com with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 16 Jul 2012 17:19:26 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 53 Original-X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: 81.202.16.46.dyn.user.ono.com Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwAQMAAABtzGvEAAAABlBMVEUAAAD///+l2Z/dAAAA oElEQVR4nK3OsRHCMAwF0O8YQufUNIQRGIAja9CxSA55AxZgFO4coMgYrEDDQZWPIlNAjwq9 033pbOBPtbXuB6PKNBn5gZkhGa86Z4x2wE67O+06WxGD/HCOGR0deY3f9Ijwwt7rNGNf6Oac l/GuZTF1wFGKiYYHKSFAkjIo1b6sCYS1sVmFhhhahKQssRjRT90ITWUk6vvK3RsPGs+M1RuR mV+hO/VvFAAAAABJRU5ErkJggg== X-Accept-Language: fr, es, en User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.4 (gnu/linux) Cancel-Lock: sha1:YWJjNWRiMjhhYmFjYmEyYzg0MjE3OWI5OWRiYjFiYmZhNWMwZjhmOQ== X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 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:151670 Archived-At: Lennart Borgman writes: > On Mon, Jul 16, 2012 at 5:00 PM, Pascal J. Bourguignon > wrote: >> Bastien writes: >> >>> 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. > ... >> Technically, one good reason to signal an error instead of silently >> clipping the arguments is that exactly it detects an error. Since lisp > > It is a good reason not to change the old behaviour. However > introducing a new function in Emacs like the one you suggest would > save time for all those who need this function. (It is hard for me > even to come up with an example where I do not want this instead of > the old one.) You cut out the relevant part: Well, lisp has this great advantage over other programming languages that it is really very accomodating to your specific needs. Look how emacs lisp provides a cl package with macros and functions similar to those provided in Common Lisp. Similarly, nothing prevents you to write an emacs lisp package with macros and functions having a Javascript, or Ruby or Python or C++ look-and-feel, that would help programmers coming from those languages to more easily adapt and feel more comfortable with emacs lisp, just like cl helps me, a Common Lisp programmer, be more comfortable with emacs lisp. (require 'js) (js-substring "abc" "0" 1000) --> "abc" ; and let JavaScript ; programmers be happy! (just document those functions and macros well, so that other emacs lisp programmers can still understand what's happening). -- __Pascal Bourguignon__ http://www.informatimago.com/ A bad day in () is better than a good day in {}.