From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Andy Wingo Newsgroups: gmane.lisp.guile.devel Subject: Re: read-all ? Date: Tue, 22 Jan 2013 12:04:51 +0100 Message-ID: <87liblwka4.fsf@pobox.com> References: <87hammwbj0.fsf@pobox.com> <87y5fyt7tn.fsf@gnu.org> <877gn5zih2.fsf@pobox.com> <87k3r5y28j.fsf@pobox.com> <8738xtk03k.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1358852707 8641 80.91.229.3 (22 Jan 2013 11:05:07 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 22 Jan 2013 11:05:07 +0000 (UTC) Cc: guile-devel@gnu.org To: ludo@gnu.org (Ludovic =?utf-8?Q?Court=C3=A8s?=) Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Tue Jan 22 12:05:26 2013 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 1TxbfL-0002H1-13 for guile-devel@m.gmane.org; Tue, 22 Jan 2013 12:05:19 +0100 Original-Received: from localhost ([::1]:40040 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Txbf3-0006EU-Lc for guile-devel@m.gmane.org; Tue, 22 Jan 2013 06:05:01 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:52021) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Txbez-0006Cq-Em for guile-devel@gnu.org; Tue, 22 Jan 2013 06:05:00 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Txbex-00081c-Of for guile-devel@gnu.org; Tue, 22 Jan 2013 06:04:57 -0500 Original-Received: from a-pb-sasl-quonix.pobox.com ([208.72.237.25]:58000 helo=sasl.smtp.pobox.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Txbex-00081W-Jn; Tue, 22 Jan 2013 06:04:55 -0500 Original-Received: from sasl.smtp.pobox.com (unknown [127.0.0.1]) by a-pb-sasl-quonix.pobox.com (Postfix) with ESMTP id F09A3A71B; Tue, 22 Jan 2013 06:04:54 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type:content-transfer-encoding; s=sasl; bh=NMIPzZPECiwC xt2JOi4fK6h0cvY=; b=d1tIrDroYluA3QiXpZWFNKEqG4Igu2DZxNZgKvRe4w5Q JFmc1bmpcWFvoKvn2+YH2YNZIz2XW+8xS3NF/p7Eb65rXurH1ottoRUAlRm7G6jm RaA+1eQSs5V3hSFL/Em24gIwWOsRMNLpgpKzJwrA+L7utGMXxHhveHAnyYqzfYI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type:content-transfer-encoding; q=dns; s=sasl; b=h+tnNb E3SJGW0lt/y2KrpgkTDUY5bZbd6ArsebxM3XYfLVJ7Mhe1IRNx7py3I10KSAMEb4 PqBTAMPe/u/0vdwHo8wwtsHmWO429hol/JumMeanrgDJ5Vhmyk7Y+VMQHFWmjOvy EBSJnolvhARYFZEVs0NbYpx350qN4r7PT8YP4= Original-Received: from a-pb-sasl-quonix.pobox.com (unknown [127.0.0.1]) by a-pb-sasl-quonix.pobox.com (Postfix) with ESMTP id E727FA71A; Tue, 22 Jan 2013 06:04:54 -0500 (EST) Original-Received: from badger (unknown [88.160.190.192]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by a-pb-sasl-quonix.pobox.com (Postfix) with ESMTPSA id 58DD9A719; Tue, 22 Jan 2013 06:04:54 -0500 (EST) In-Reply-To: <8738xtk03k.fsf@gnu.org> ("Ludovic =?utf-8?Q?Court=C3=A8s=22'?= =?utf-8?Q?s?= message of "Tue, 22 Jan 2013 11:01:35 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2 (gnu/linux) X-Pobox-Relay-ID: 8D1519B4-6483-11E2-B715-0A4F0E5B5709-02397024!a-pb-sasl-quonix.pobox.com X-detected-operating-system: by eggs.gnu.org: Solaris 10 X-Received-From: 208.72.237.25 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:15530 Archived-At: On Tue 22 Jan 2013 11:01, ludo@gnu.org (Ludovic Court=C3=A8s) writes: >>> Are the names right? > > =E2=80=98read-all=E2=80=99 doesn=E2=80=99t convey the idea that it=E2=80= =99s textual (unlike the R6RS > names). > > Perhaps =E2=80=98port-contents-as-string=E2=80=99, or =E2=80=98read-all-s= tring=E2=80=99, or...? What about read-string with an optional #:count argument ? >> + (let lp ((n start)) >> + (if (< n end) >> + (let ((c (read-char port))) >> + (if (eof-object? c) >> + (- n start) >> + (begin >> + (string-set! buf n c) >> + (lp (1+ n))))) >> + (- n start)))) > > As you note, this is fairly inefficient, like =E2=80=98get-string-n!=E2= =80=99. It is exactly what %read-delimited does, though, and that's the most efficient thing we have. read-string/partial! does something more clever, but I don't understand it fully. I was thinking (ice-9 ports) could be appropriate if we exposed port buffers to scheme, because that way we could read characters in bulk. Dunno. > Given that =E2=80=98string-set!=E2=80=99 is (unduly) costly, I wonder if = consing all the > chars and then calling =E2=80=98list->string=E2=80=99 wouldn=E2=80=99t be= more efficient in time > (it=E2=80=99d be less efficient in space.) Probably not, I would say that the interface is more important than the implementation. So, proposal: read-all{,!} to read-string{,!} and add optional count argument to read-string, and leave it in ice-9 rdelim. WDYT? Andy --=20 http://wingolog.org/