From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: "Stephen J. Turnbull" Newsgroups: gmane.emacs.xemacs.design,gmane.emacs.devel Subject: Re: Rationale for split-string? Date: Mon, 21 Apr 2003 19:58:48 +0900 Organization: The XEmacs Project Sender: xemacs-design-admin@xemacs.org Message-ID: <87ist8yv4n.fsf@tleepslib.sk.tsukuba.ac.jp> References: <87brz57at2.fsf@tleepslib.sk.tsukuba.ac.jp> <200304171744.h3HHiJCx009215@rum.cs.yale.edu> <87adem27ey.fsf@tleepslib.sk.tsukuba.ac.jp> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: main.gmane.org 1050922817 15165 80.91.224.249 (21 Apr 2003 11:00:17 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Mon, 21 Apr 2003 11:00:17 +0000 (UTC) Cc: emacs-devel@gnu.org, xemacs-design@xemacs.org Original-X-From: xemacs-design-admin@xemacs.org Mon Apr 21 13:00:06 2003 Return-path: Original-Received: from gwyn.tux.org ([199.184.165.135]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 197Z1o-0003vY-00 for ; Mon, 21 Apr 2003 13:00:04 +0200 Original-Received: from gwyn.tux.org (localhost.localdomain [127.0.0.1]) by gwyn.tux.org (8.11.6p2/8.9.1) with ESMTP id h3LB08M24085; Mon, 21 Apr 2003 07:00:08 -0400 Original-Received: (from turnbull@localhost) by gwyn.tux.org (8.11.6p2/8.9.1) id h3LAxpf23770 for xemacs-design-mailman@xemacs.org; Mon, 21 Apr 2003 06:59:51 -0400 Original-Received: (from mail@localhost) by gwyn.tux.org (8.11.6p2/8.9.1) id h3LAxoC23749 for turnbull@tux.org; Mon, 21 Apr 2003 06:59:50 -0400 Original-Received: from tleepslib.sk.tsukuba.ac.jp (tleepslib.sk.tsukuba.ac.jp [130.158.98.109]) by gwyn.tux.org (8.11.6p2/8.9.1) with ESMTP id h3LAxhM23720 for ; Mon, 21 Apr 2003 06:59:48 -0400 Original-Received: from steve by tleepslib.sk.tsukuba.ac.jp with local (Exim 3.36 #1 (Debian)) id 197Z0a-0003IZ-00; Mon, 21 Apr 2003 19:58:48 +0900 Original-To: rms@gnu.org In-Reply-To: (Richard Stallman's message of "Sun, 20 Apr 2003 20:59:46 -0400") User-Agent: Gnus/5.090016 (Oort Gnus v0.16) XEmacs/21.5 (cabbage) X-XEmacs-List: design Errors-To: xemacs-design-admin@xemacs.org X-BeenThere: xemacs-design@xemacs.org X-Mailman-Version: 2.0.13 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: Discussion of design and features for XEmacs. List-Unsubscribe: , Xref: main.gmane.org gmane.emacs.xemacs.design:2084 gmane.emacs.devel:13318 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:13318 >>>>> "rms" == Richard Stallman writes: rms> I don't entirely agree. The default case uses strings of rms> whitespace as the separator, and for that case, the only rms> intelligent approach is token-parsing. So the function needs rms> to be able to do token-parsing. I was afraid of that (I prefer regular behavior over intelligent behavior if I must make a choice), but I can live with it. I really would prefer a separate `tokenize-string' function, though. (That name is not used in the GNU Emacs or XEmacs cores, or anywhere in the XEmacs packages. Several packages have their own tokenize functions but they're all properly prefixed, and one might fear semantic would use the name, but it doesn't.) rms> This feature therefore may as well also be available for any rms> separator. But that's not compatible with a *single* function with with *two* arguments. So I suppose you want a simpler version of Luc Teirlinck's suggestion. How about: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; one function, three arguments (defun split-string (string &optional separators omit-nulls) "Splits STRING into substrings bounded by matches for SEPARATORS. The beginning and end of STRING, and each match for SEPARATORS, are splitting points. The substrings between the splitting points are collected in a list, which is returned. (The substrings matching SEPARATORS are removed.) If SEPARATORS is nil, it defaults to \"[ \f\t\n\r\v]+\". If OMIT-NULLs is t, zero-length substrings are omitted from the list (so that for the default value of SEPARATORS leading and trailing whitespace are trimmed). If nil, all zero-length substrings are retained, which correctly parses CSV format, for example." ;; implementation ) -- Institute of Policy and Planning Sciences http://turnbull.sk.tsukuba.ac.jp University of Tsukuba Tennodai 1-1-1 Tsukuba 305-8573 JAPAN Ask not how you can "do" free software business; ask what your business can "do for" free software.