From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Kenichi Handa Newsgroups: gmane.emacs.devel Subject: Re: request for a new function, say, `sequence' Date: Wed, 26 Mar 2003 09:18:58 +0900 (JST) Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: <200303260018.JAA08092@etlken.m17n.org> 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> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 (generated by SEMI 1.14.3 - "Ushinoya") Content-Type: text/plain; charset=US-ASCII X-Trace: main.gmane.org 1048638486 32056 80.91.224.249 (26 Mar 2003 00:28:06 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Wed, 26 Mar 2003 00:28:06 +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 01:28:01 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 18xylt-0008KU-00 for ; Wed, 26 Mar 2003 01:28:01 +0100 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.12 #1 (Debian)) id 18xyn2-0002qn-00 for ; Wed, 26 Mar 2003 01:29:12 +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 18xygs-00079I-03 for emacs-devel@quimby.gnus.org; Tue, 25 Mar 2003 19:22:50 -0500 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.10.13) id 18xyfx-0006rI-00 for emacs-devel@gnu.org; Tue, 25 Mar 2003 19:21:53 -0500 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.10.13) id 18xyep-0006Vt-00 for emacs-devel@gnu.org; Tue, 25 Mar 2003 19:20:46 -0500 Original-Received: from tsukuba.m17n.org ([192.47.44.130]) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 18xydI-0006GW-00 for emacs-devel@gnu.org; Tue, 25 Mar 2003 19:19:08 -0500 Original-Received: from fs.m17n.org (fs.m17n.org [192.47.44.2])h2Q0Ix906424; Wed, 26 Mar 2003 09:18:59 +0900 (JST) (envelope-from handa@m17n.org) Original-Received: from etlken.m17n.org (etlken.m17n.org [192.47.44.125]) h2Q0IwA26278; Wed, 26 Mar 2003 09:18:58 +0900 (JST) Original-Received: (from handa@localhost) by etlken.m17n.org (8.8.8+Sun/3.7W-2001040620) id JAA08092; Wed, 26 Mar 2003 09:18:58 +0900 (JST) Original-To: satyakid@stanford.edu In-reply-to: <24784.1048623017@theforce.Stanford.EDU> (satyakid@stanford.edu) User-Agent: SEMI/1.14.3 (Ushinoya) FLIM/1.14.2 (Yagi-Nishiguchi) APEL/10.2 Emacs/21.2.92 (sparc-sun-solaris2.6) MULE/5.0 (SAKAKI) 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:12615 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:12615 In article <24784.1048623017@theforce.Stanford.EDU>, "Satyaki Das" writes: >> >> (defun dev-charseq (from &optional to) >> >> (if (null to) (setq to from)) >> >> (mapcar (function (lambda (x) (indian-glyph-char x 'devanagari))) >> >> (devanagari-range from to))) >> >> > (defun dev-charseq (lower &optional upper) >> > (if (null upper) (setq upper lower)) >> > (loop for x from lower to upper >> > collect (indian-glyph-char x 'devanagiri))) >> >> It's not the point. How to use a list returned by `range' >> (or `sequence') and how to make such a list is a different >> thing. > I am trying to show that by using existing macros and functions we > can express the algorithms as clearly and succintly as with the > new `range'. 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. > 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. 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))) but using `range' is much more handy and easier to read. > 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. And, `range' surely makes writing code easier and makes the code simpler as well as dolist, dotimes, while, and etc. do. > I think calling the new function `sequence' or `range' is a > mistake. Lisp already has the functions `string' and `vector' > which are data type constructors. Either of the suggested names > sound like a new data type (in fact there is already a data type > called sequence and a predicate sequencep) and so inconsistent > with the current naming conventions. I see your point. > 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. --- Ken'ichi HANDA handa@m17n.org