From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: "Satyaki Das" Newsgroups: gmane.emacs.devel Subject: Re: request for a new function, say, `sequence' Date: Tue, 25 Mar 2003 17:44:02 -0800 Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: <31827.1048643042@theforce.Stanford.EDU> References: <200303230302.MAA04327@etlken.m17n.org> <200303241541.h2OFfbpa011227@rum.cs.yale.edu> <200303250015.JAA06592@etlken.m17n.org> <200303250050.JAA06631@etlken.m17n.org> <200303250057.h2P0vBj6016367@rum.cs.yale.edu> <200303250125.KAA06703@etlken.m17n.org> <32627.1048557446@theforce.Stanford.EDU> <200303250208.LAA06802@etlken.m17n.org> <1191.1048560083@theforce.Stanford.EDU> <200303250446.NAA06974@etlken.m17n.org> <4946.1048568708@theforce.Stanford.EDU> <200303250540.OAA07032@etlken.m17n.org> <24784.1048623017@theforce.Stanford.EDU> <200303260018.JAA08092@etlken.m17n.org> NNTP-Posting-Host: main.gmane.org X-Trace: main.gmane.org 1048643137 27591 80.91.224.249 (26 Mar 2003 01:45:37 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Wed, 26 Mar 2003 01:45:37 +0000 (UTC) Cc: monnier+gnu/emacs@rum.cs.yale.edu Original-X-From: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Wed Mar 26 02:45:35 2003 Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 18xzyx-0007Aq-00 for ; Wed, 26 Mar 2003 02:45:35 +0100 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.12 #1 (Debian)) id 18y007-0003ZH-00 for ; Wed, 26 Mar 2003 02:46:47 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 18xzxr-0007Y5-01 for emacs-devel@quimby.gnus.org; Tue, 25 Mar 2003 20:44:27 -0500 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.10.13) id 18xzxY-0007Xj-00 for emacs-devel@gnu.org; Tue, 25 Mar 2003 20:44:08 -0500 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.10.13) id 18xzxX-0007WG-00 for emacs-devel@gnu.org; Tue, 25 Mar 2003 20:44:08 -0500 Original-Received: from chicory.stanford.edu ([171.64.73.212]) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 18xzxX-0007W9-00 for emacs-devel@gnu.org; Tue, 25 Mar 2003 20:44:07 -0500 Original-Received: from dwarka.stanford.edu (ev-01-st2435.Stanford.EDU [128.12.141.17]) by chicory.Stanford.EDU (8.11.6/8.11.6) with ESMTP id h2Q1i9x01598; Tue, 25 Mar 2003 17:44:09 -0800 Original-Received: from troodon.stanford.edu (troodon.Stanford.EDU [171.64.73.3]) (using TLSv1 with cipher EDH-RSA-DES-CBC3-SHA (168/168 bits)) (No client certificate requested) by dwarka.stanford.edu (Postfix) with ESMTP id 8C0899D14; Tue, 25 Mar 2003 17:44:13 -0800 (PST) Original-Received: from [127.0.0.1] (helo=theforce.Stanford.EDU) by troodon.stanford.edu with esmtp (Exim 4.12) id 18xzxS-0008HN-00; Tue, 25 Mar 2003 17:44:02 -0800 Original-To: Kenichi Handa In-Reply-To: <200303260018.JAA08092@etlken.m17n.org> X-Mailer: MH-E 7.2+cvs; nmh 1.1; GNU Emacs 21.3.50.4 Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAGFBMVEX59eDEg08pDhCGQSiw azzFmmfl2rvNtIz0M43EAAACVklEQVR4nGWUQXPbIBCFOSnXMIHmjpzptdLi9IxB0zONKVdf gq91U4m/37dIcZzpjmds62PfW5ZFolSOpQhRSoc/KeXl1J2leAdzrmVZap1X4MR5BX8MR//M oJy6O7mB2azxtEl1UeAhVH5uwNgGhIjISDnl8R2YHUsxgGhKb+YjUgWA1MzgYHqiQEQAE4O7 KFKKKRlDoQUkv2/gGEJ8MX1wTqoQkPK1whzl8rqDsU7KCOLHT2DEczilqKD11EBswFipM7aZ JLSetgziWlYwpyj9f4D7ArHwGXinFzRthr/ZtXJX0I+GHkuN3lplem7JnWIw9uRpqBci68PY pxswpFk+XmSepQRYGkATaOcHHQGk1PKw2zLQNrJESk3xwQYnD1aX31fgKXonH8gP8YDKkREY DBYiWKzQMOljA5zRD1YnBjrqpIK8ArI2zTFMSqcclUupbh5EQ64Xl+OEL/UjaYDuCo5eK5nL DJ8GjmtVAOi+e0SGU9MVWKu1bLtjjxW0ffRKYzmY0visoO3DHPUDWekpALhwk2FlDLpGLROy wodHT04GnVPCoEzH2wwKbI2DlQogXAHqRUOijujYpFawmuMEHVergp2CBzitoM/eBsW+nvZ/ KeSlNNAv5xeIceCcfxW+kQz6Rby+USM8MDxVpZyD2OGWvGbaYuwL3+wOANdKlPyG0w3B+vG5 FL5p4iw4ylwhBDG/P3Ug4j26c51Rf/B14RdES1lBWSpmze15cXcDuIyKefvWHt1q4XepUt2v a2/ACa+PEuU9ZhBa3a0JwCV+aUA0k3+tF/9WVaqmbwAAAABJRU5ErkJggg== Original-cc: emacs-devel@gnu.org X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1b5 Precedence: list List-Id: Emacs development discussions. List-Help: List-Post: List-Subscribe: , List-Archive: List-Unsubscribe: , Errors-To: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:12621 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:12621 Kenichi Handa writes: > In your example code, you united the implementaion of range > and usage of the returned list. In such a way, of course, > it is natural that we can make a function that uses `range' > more concise and efficient. This should be done only if it doesn't affect the readability and simplicity of the code. > > Do you have a counter-example to this? > > How about the code something like this. > > (defvar dev-consonants > (append (range (decode-char 'ucs #x0915) (decode-char 'ucs #x0939)) > (range (decode-char 'ucs #x0958) (decode-char 'ucs #x095F)))) > > (defun dev-looking-at-syllable () > (and (memq (following-char) dev-consonants) > (looking-at dev-syllable-pattern))) > > The first `memq' is to avoid the heavy `looking-at' in an > unnecessary case. This seems like a reasonable usage scenario for `range'. However since you are doing this for efficiency reasons, isn't it more efficient to compare with <= than to use memq to to compare it with 45 separate integers? > The defvar part can be written as: > > (defvar dev-consonants > (append (loop for x from (decode-char 'ucs #x0915) to (decode-char 'ucs #x0939) > collect x) > (loop for x from (decode-char 'ucs #x0958) to (decode-char 'ucs #x095F) > collect x))) Or you could do it in one loop and collect with a when. But I agree that this could easily get quite hairy if there are lots of ranges to consider. > but using `range' is much more handy and easier to read. Agreed. > > IMO, a new builtin function is needed if and only if it makes > > writing code easier or makes it simpler. > > I'm not requesting a builtin function. Sorry about the bad terminology. I meant a library function. > And, `range' surely > makes writing code easier and makes the code simpler as well > as dolist, dotimes, while, and etc. do. Agreed. But I would be careful in its use, since it can potentially cons a lot (if used inside of a loop for instance). > > So I suggest that a more descriptive name be chosen -- for > > instance something like `make-sequence-of-numbers'. > > I don't insist on having TYPE argument, always returning a > list is ok. So, for instance, make-number-list, is also > acceptable. Yes, this seems reasonable if you don't want the vectors and string types. Satyaki