guile-user
[Top][All Lists]
Advanced

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

Re: I/O, modules


From: Ludovic Courtès
Subject: Re: I/O, modules
Date: Tue, 13 Nov 2012 10:31:59 +0100
User-agent: Gnus/5.130005 (Ma Gnus v0.5) Emacs/24.2 (gnu/linux)

Hi,

address@hidden 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 ‘read-line’ function, which reads a line from a port.

For binary I/O, search for (rnrs io ports).  You’ll get a variety of
procedures, including ‘get-bytevector-all’, 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 ‘test-scm.scm’ is not in the search path.

The fix is to run:

  guile -L . import-test.scm

Thanks,
Ludo’.



reply via email to

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