mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-13 07:10:20 +02:00
Added (use-modules (ice-9 rdelim)) to an example that uses read-line.
Thanks to Ralf Mattes!
This commit is contained in:
parent
c5ee546dda
commit
4310df3688
2 changed files with 14 additions and 3 deletions
|
@ -738,11 +738,14 @@ currently running Guile REPL or the top of your script file.
|
||||||
@end lisp
|
@end lisp
|
||||||
|
|
||||||
This will load the module and make the procedures exported by
|
This will load the module and make the procedures exported by
|
||||||
@code{(ice-9 popen)} automatically available. The next step could be to
|
@code{(ice-9 popen)} automatically available. The next step could be
|
||||||
open a pipe to @file{ls} and read the contents of the current directory,
|
to open a pipe to @file{ls} and read the contents of the current
|
||||||
one line at a time.
|
directory, one line at a time. For the latter, we use the function
|
||||||
|
@code{read-line}, which can be found in the module @code{(ice-9
|
||||||
|
rdelim)}, so we use that module as well.
|
||||||
|
|
||||||
@lisp
|
@lisp
|
||||||
|
(use-modules (ice-9 rdelim))
|
||||||
(define p (open-input-pipe "ls -l"))
|
(define p (open-input-pipe "ls -l"))
|
||||||
(read-line p)
|
(read-line p)
|
||||||
@result{}
|
@result{}
|
||||||
|
@ -752,6 +755,13 @@ one line at a time.
|
||||||
"drwxr-sr-x 2 mgrabmue mgrabmue 1024 Mar 29 19:57 CVS"
|
"drwxr-sr-x 2 mgrabmue mgrabmue 1024 Mar 29 19:57 CVS"
|
||||||
@end lisp
|
@end lisp
|
||||||
|
|
||||||
|
The macro @code{use-modules} can take any number of modules to use.
|
||||||
|
Therefore, we could have written the two @code{use-modules} statements
|
||||||
|
in the code above as
|
||||||
|
|
||||||
|
@lisp
|
||||||
|
(use-modules (ice-9 popen) (ice-9 rdelim))
|
||||||
|
@end lisp
|
||||||
|
|
||||||
@node Intro to Writing New Modules
|
@node Intro to Writing New Modules
|
||||||
@subsection Intro to Writing New Modules
|
@subsection Intro to Writing New Modules
|
||||||
|
|
|
@ -1069,6 +1069,7 @@ defined previously, using @code{define-reader-ctor}.
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
@lisp
|
@lisp
|
||||||
|
(use-modules (ice-9 rdelim)) ; for read-line
|
||||||
(define-reader-ctor 'file open-input-file)
|
(define-reader-ctor 'file open-input-file)
|
||||||
(define f '#,(file "/etc/passwd"))
|
(define f '#,(file "/etc/passwd"))
|
||||||
(read-line f)
|
(read-line f)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue