[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Difference between pipes and ports
From: |
Zelphir Kaltstahl |
Subject: |
Difference between pipes and ports |
Date: |
Wed, 11 Aug 2021 01:14:13 +0000 |
Hello Guile users,
I recently came across
https://www.draketo.de/software/guile-capture-stdout-stderr.html
<https://www.draketo.de/software/guile-capture-stdout-stderr.html> and wrote a
commented version at
https://notabug.org/ZelphirKaltstahl/guile-examples/src/master/input-output/stdout-stderr.scm
<https://notabug.org/ZelphirKaltstahl/guile-examples/src/master/input-output/stdout-stderr.scm>.
While looking at the code, I was starting to wonder, what the difference between
a pipe and a port is. The reference manual does not say much about any
definition of what a pipe is at
https://www.gnu.org/software/guile/manual/html_node/Pipes.html
<https://www.gnu.org/software/guile/manual/html_node/Pipes.html> and pipe
procedure return values are also named port.
However, in the REPL, they look not the same:
~~~~
scheme@(guile-user)> (import (ice-9 popen))
scheme@(guile-user)> (open-input-pipe "ls -al")
$2 = #<input: #{read pipe}# 13>
~~~~
And here for ports:
~~~~
scheme@(guile-user)> (call-with-output-string
(λ (port)
(display port)))
#<output: file 7fa2a99471c0>$6 = ""
~~~~
Is a pipe just a special kind of port? Does it wrap a port? Or is it perhaps
merely a different terminology used in different contexts in the reference
manual?
Best regards,
Zelphir
--
repositories: https://notabug.org/ZelphirKaltstahl
- Difference between pipes and ports,
Zelphir Kaltstahl <=