From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: ludo@gnu.org (Ludovic =?utf-8?Q?Court=C3=A8s?=) Newsgroups: gmane.lisp.guile.user Subject: Re: I/O, modules Date: Tue, 13 Nov 2012 10:31:59 +0100 Message-ID: <87a9ulonlc.fsf@gnu.org> References: <42782.199.48.147.41.1352786231.squirrel@lavabit.com> 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 1352799142 5339 80.91.229.3 (13 Nov 2012 09:32:22 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 13 Nov 2012 09:32:22 +0000 (UTC) Cc: guile-user@gnu.org To: thorsopia@lavabit.com Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Tue Nov 13 10:32:33 2012 Return-path: Envelope-to: guile-user@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 1TYCr9-00035H-ER for guile-user@m.gmane.org; Tue, 13 Nov 2012 10:32:31 +0100 Original-Received: from localhost ([::1]:34442 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TYCqz-0006C7-Np for guile-user@m.gmane.org; Tue, 13 Nov 2012 04:32:21 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:32819) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TYCqs-0006Bi-PA for guile-user@gnu.org; Tue, 13 Nov 2012 04:32:17 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TYCqp-00067A-M1 for guile-user@gnu.org; Tue, 13 Nov 2012 04:32:14 -0500 Original-Received: from xanadu.aquilenet.fr ([88.191.123.111]:50360) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TYCqp-00066s-G7 for guile-user@gnu.org; Tue, 13 Nov 2012 04:32:11 -0500 Original-Received: from localhost (localhost [127.0.0.1]) by xanadu.aquilenet.fr (Postfix) with ESMTP id 91FD16A87; Tue, 13 Nov 2012 10:31:59 +0100 (CET) Original-Received: from xanadu.aquilenet.fr ([127.0.0.1]) by localhost (xanadu.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id fwrgC3dRKL5H; Tue, 13 Nov 2012 10:31:59 +0100 (CET) Original-Received: from pluto (unknown [193.50.110.189]) by xanadu.aquilenet.fr (Postfix) with ESMTPSA id 4A96A2E99; Tue, 13 Nov 2012 10:31:59 +0100 (CET) X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: 23 Brumaire an 221 de la =?utf-8?Q?R=C3=A9volution?= X-PGP-Key-ID: 0xEA52ECF4 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 83C4 F8E5 10A3 3B4C 5BEA D15D 77DD 95E2 EA52 ECF4 X-OS: x86_64-unknown-linux-gnu In-Reply-To: <42782.199.48.147.41.1352786231.squirrel@lavabit.com> (thorsopia@lavabit.com's message of "Tue, 13 Nov 2012 00:57:11 -0500 (EST)") User-Agent: Gnus/5.130005 (Ma Gnus v0.5) Emacs/24.2 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 88.191.123.111 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Original-Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.user:9668 Archived-At: Hi, thorsopia@lavabit.com skribis: > Could you show me some trivial programs related to I/O (e.g. read from > file, convert to uppercase, write to another file)? > > This page [0] doesn't list a function that can be used to read the whole > file at once. Is there a "read-string" function? What about "read-port"? For textual I/O, search the manual for (ice-9 rdelim). This module provides a =E2=80=98read-line=E2=80=99 function, which reads a line from a = port. For binary I/O, search for (rnrs io ports). You=E2=80=99ll get a variety of procedures, including =E2=80=98get-bytevector-all=E2=80=99, which reads all= of a ports contents in memory. > I created two files in the same dir: > > test-scm.scm: > > (define-module (test-scm) > #:export (test-func)) > > (define (test-func x) > (+ x 1)) > > import-test.scm: > > (define-module (import-test) > #:use-module (test-scm)) > > (display (test-func 2)) > > Why does "guile import-test.scm" raise "ERROR: no code for module > (test-scm)"? Because =E2=80=98test-scm.scm=E2=80=99 is not in the search path. The fix is to run: guile -L . import-test.scm Thanks, Ludo=E2=80=99.