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: Sat, 19 Apr 2003 17:55:17 +0900 Organization: The XEmacs Project Sender: xemacs-design-admin@xemacs.org Message-ID: <87adem27ey.fsf@tleepslib.sk.tsukuba.ac.jp> References: <87brz57at2.fsf@tleepslib.sk.tsukuba.ac.jp> <200304171744.h3HHiJCx009215@rum.cs.yale.edu> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: main.gmane.org 1050742586 30817 80.91.224.249 (19 Apr 2003 08:56:26 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Sat, 19 Apr 2003 08:56:26 +0000 (UTC) Cc: emacs-devel@gnu.org, xemacs-design@xemacs.org Original-X-From: xemacs-design-admin@xemacs.org Sat Apr 19 10:56:24 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 196o92-00080v-00 for ; Sat, 19 Apr 2003 10:56:24 +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 h3J8v1M06320; Sat, 19 Apr 2003 04:57:01 -0400 Original-Received: (from turnbull@localhost) by gwyn.tux.org (8.11.6p2/8.9.1) id h3J8uIW06083 for xemacs-design-mailman@xemacs.org; Sat, 19 Apr 2003 04:56:18 -0400 Original-Received: (from mail@localhost) by gwyn.tux.org (8.11.6p2/8.9.1) id h3J8uFb06060 for turnbull@tux.org; Sat, 19 Apr 2003 04:56:15 -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 h3J8uDM06050 for ; Sat, 19 Apr 2003 04:56:13 -0400 Original-Received: from steve by tleepslib.sk.tsukuba.ac.jp with local (Exim 3.36 #1 (Debian)) id 196o7x-0005oK-00; Sat, 19 Apr 2003 17:55:17 +0900 Original-To: rms@gnu.org In-Reply-To: (Richard Stallman's message of "Sat, 19 Apr 2003 00:14:31 -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:2073 gmane.emacs.devel:13296 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:13296 > (split-string ",,data,," ",") > => ("" "data" "") rms> Is that wrong? If so, what result do you think is right? rms> ("" "" "data" "" "") could be argued for, but I am not sure rms> it is better. Well, if you are parsing a comma separated value file (the standard text/plain output format for spreadsheets and some databases, such as subversion), the five-element list is exactly what you want, and the three-element list is a type error (incomplete record). In what case would the three-element list be desirable? I understand the case for a one-element result, but not three. I see basically two modes. In one mode you are parsing fields from each of a sequence of records, in which case you want to retain null strings as null values. In the other, you are parsing a (free-form) stream of words, in which case null words (usually) don't exist, so you want to throw away _all_ of the null strings. In fact, all of the whitespace-only strings, too, but those normally won't arise in the common case where SEPARATORS matches contiguous whitespace. I think we should support both modes, but the token-parser is easy to derive from the field-parser, while it's impossible to do the reverse because the token parser throws away information. I conclude that the field-parser (the XEmacs behavior) is more primitive, and I'd like to call that `split-string', with either more sophisticated behavior implemented by overloading the separators argument to take keywords for special treatment, or (preferably) in a separate function. -- 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.