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: Rationale for split-string? Date: Thu, 17 Apr 2003 18:06:17 +0900 Organization: The XEmacs Project Sender: xemacs-design-admin@xemacs.org Message-ID: <87brz57at2.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 1050570475 14065 80.91.224.249 (17 Apr 2003 09:07:55 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Thu, 17 Apr 2003 09:07:55 +0000 (UTC) Cc: xemacs-design@xemacs.org Original-X-From: xemacs-design-admin@xemacs.org Thu Apr 17 11:07:53 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 1965N3-0003eX-00 for ; Thu, 17 Apr 2003 11:07:53 +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 h3H986M20000; Thu, 17 Apr 2003 05:08:06 -0400 Original-Received: (from turnbull@localhost) by gwyn.tux.org (8.11.6p2/8.9.1) id h3H97UX19913 for xemacs-design-mailman@xemacs.org; Thu, 17 Apr 2003 05:07:30 -0400 Original-Received: (from mail@localhost) by gwyn.tux.org (8.11.6p2/8.9.1) id h3H97J719881 for turnbull@tux.org; Thu, 17 Apr 2003 05:07:19 -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 h3H97CM19852 for ; Thu, 17 Apr 2003 05:07:13 -0400 Original-Received: from steve by tleepslib.sk.tsukuba.ac.jp with local (Exim 3.36 #1 (Debian)) id 1965LW-0006QT-00; Thu, 17 Apr 2003 18:06:18 +0900 Original-To: emacs-devel@gnu.org 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:2038 gmane.emacs.devel:13262 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:13262 What is the rationale for the specification of `split-string'? That is, in GNU Emacs ;; an often convenient abbreviation (split-string " data ") => ("data") ;; weird (split-string " data " " ") => ("" "data" "") ;; urk (think "gnumeric just-say-no.xls" "save as" "csv") (split-string ",,data,," ",") => ("" "data" "") emacs-version "21.2.2" In XEmacs currently we get ;; usually (delete "" (split-string " data ")) should do the ;; trick if you don't like this (split-string " data ") => ("" "data" "") ;; no less useful than what GNU Emacs returns (split-string " data " " ") => ("" "" "data" "" "") ;; I can't imagine wanting anything else (split-string ",,data,," ",") => ("" "" "data" "" "") For comparison, Python's `split' function behaves like XEmacs's `split-string'. Perl's `split' function by default removes all trailing null fields while preserving all leading null fields, but when invoked "split (/pattern/, string, -1)" behaves like XEmacs's `split-string'. I think it makes sense for GNU Emacs to adopt (return to?) the simpler, more consistent behavior, rather than have XEmacs sync to GNU Emacs. In particular, I think it's really unfortunate to force people who want to parse csv data and the like to write their own functions, while the `(delete "" (split-string ...))' idiom not only seems very natural to me, but it handles the second example better than GNU Emacs currently does. And while I'm sure there exist applications where trimming null fields at the ends but leaving them when surrounded by non-null ones make sense, I can't come up with one offhand. I suspect they're less common than either "remove all nulls" or "keep all nulls". I believe that (at least for third-party maintainers) this change should cause no problems, because we have had no complaints about the behavior from anyone. (We discovered the difference only when Ben started a sync, and the regression test sent up flares and alarums.) -- 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.