From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Chris K. Jester-Young" Newsgroups: gmane.lisp.guile.devel Subject: Re: regexp-split for Guile Date: Mon, 17 Sep 2012 16:06:03 -0400 Message-ID: <20120917200603.GB6315@yarrow> References: <20120917140133.GA6315@yarrow> <87lig830ox.fsf@zigzag.favinet> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1347912373 20132 80.91.229.3 (17 Sep 2012 20:06:13 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 17 Sep 2012 20:06:13 +0000 (UTC) To: guile-devel@gnu.org Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Mon Sep 17 22:06:18 2012 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1TDhaC-0001Oq-1B for guile-devel@m.gmane.org; Mon, 17 Sep 2012 22:06:16 +0200 Original-Received: from localhost ([::1]:33262 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TDha7-0001mm-Of for guile-devel@m.gmane.org; Mon, 17 Sep 2012 16:06:11 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:33099) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TDha4-0001ma-LF for guile-devel@gnu.org; Mon, 17 Sep 2012 16:06:09 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TDha3-0006qz-H0 for guile-devel@gnu.org; Mon, 17 Sep 2012 16:06:08 -0400 Original-Received: from mail-vc0-f169.google.com ([209.85.220.169]:38399) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TDha3-0006qs-C1 for guile-devel@gnu.org; Mon, 17 Sep 2012 16:06:07 -0400 Original-Received: by vcbfl17 with SMTP id fl17so5705223vcb.0 for ; Mon, 17 Sep 2012 13:06:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:subject:message-id:mail-followup-to:references :mime-version:content-type:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=664rBdQNhzpjqLPWFN/D1S7IkOLIsjmJDEB6QIqIQ6s=; b=v0UGBj/K0iaGrylcWf/BU8h7z5Fi/6JDUS89pYLjQAY2OYHnSSjcpl4vxrZoj9A+T2 uhec9WgINU8gI1Kv7AQyCGpKf9KLJ3ZQG4r4d9z8rIk+9sF83szDCUFh6pjzQNBohrr+ TxNQGkVoY6JAGsYqs5XcsCkl//uh6KRDbUlLXGNe5q+tYUP5CrnDfkKlZpF5msOeFOk/ Loh4Y1cQ8Rz7z5eMJuLwvr16S7IF/g2bz2gFdV9BTQtaP224N6Ox/apWJgVOztLTDp9r pjSNrv0wrNXv2ZivtJy8yX0JNvgmhAkQxeGvV76n9cYD9RdVcHVpxCvvCKaTuwtQ0WA2 PokQ== Original-Received: by 10.220.239.209 with SMTP id kx17mr8122271vcb.41.1347912366727; Mon, 17 Sep 2012 13:06:06 -0700 (PDT) Original-Received: from yarrow (cpe-069-134-140-185.nc.res.rr.com. [69.134.140.185]) by mx.google.com with ESMTPS id b7sm1644493vdv.2.2012.09.17.13.06.05 (version=SSLv3 cipher=OTHER); Mon, 17 Sep 2012 13:06:05 -0700 (PDT) Mail-Followup-To: guile-devel@gnu.org Content-Disposition: inline In-Reply-To: <87lig830ox.fsf@zigzag.favinet> User-Agent: Mutt/1.5.21 (2010-09-15) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.220.169 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:14891 Archived-At: On Mon, Sep 17, 2012 at 09:32:14PM +0200, Thien-Thi Nguyen wrote: > (define (string-empty? str) > (zero? (string-length str))) > > You can use ‘string-null?’ instead. Ah, nice! Thanks for the pointer. > Style nit: i find it easier to read ‘if’ expressions w/ the condition, > then and else expressions on separate lines. Similarly ‘cons’. E.g.: Right, that sounds like a good idea. It does make the code longer, and so for simple cases of "if" and "cons", I'd probably still keep it in one line, but in this case you do make a very clear case with the "cons" (which involves somewhat lengthier subexpressions). > A more substantial line of questioning: What happens if ‘regexp-split’ > is called w/ negative ‘limit’? Should that be handled in ‘regexp-split’ > or will the procs it calls DTRT? What is TRT, anyway? In the absence > of explicit validation, maybe a comment here will help the non-expert. So, basically, the Perl split's limit is used this way: 1. Positive limit: Return this many fields at most: (regexp-split ":" "foo:bar:baz:qux:" 3) => ("foo" "bar" "baz:qux:") 2. Negative limit: Return all fields: (regexp-split ":" "foo:bar:baz:qux:" -1) => ("foo" "bar" "baz" "qux" "") 3. Zero limit: Return all fields, after removing trailing blank fields: (regexp-split ":" "foo:bar:baz:qux:" 0) => ("foo" "bar" "baz" "qux") Because of this, the specific negative value doesn't matter; they are all treated the same. This is why the code checks for a positive limit and passes #f to fold-matches if it's not positive. I hope this makes sense. :-) Thanks so much for your feedback. I'll incorporate your comments. Cheers, Chris.