[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Rationale for split-string?

From: Miles Bader
Subject: Re: Rationale for split-string?
Date: Mon, 21 Apr 2003 19:43:47 -0400
User-agent: Mutt/1.3.28i

On Mon, Apr 21, 2003 at 04:11:21PM -0500, Luc Teirlinck wrote:
>    (defun split-string (string &optional separators omit-nulls)
> There are two problems with this.  First of, all it would break tons
> of existing Emacs code.  Secondly, the defaults for SEPARATORS and for
> OMIT-NULLs do not match.  Thus, the most routine call of 
> (split-string string) would produce nonsensical results in the case of
> leading or trailing whitespace.

Other than the all-defaults case (where _both_ optional arguments are
omitted), I think Stephen's formulation is very natural, in that you usually
want OMIT-NULLS to be t if you're splitting on a non-whitespace string.

I think the problem with the all-defaults case could be solved by having
OMIT-NULLS default to t when SEPARATORS is not specified.  This is what awk
does I think (with split), and it's really very natural.

[IOW, at the beginning of the function, put:
  (unless separators (setq omit-nulls t))

We are all lying in the gutter, but some of us are looking at the stars.
-Oscar Wilde

reply via email to

[Prev in Thread] Current Thread [Next in Thread]