From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Zelphir Kaltstahl Newsgroups: gmane.lisp.guile.user Subject: Re: Difference between pipes and ports Date: Wed, 11 Aug 2021 09:48:52 +0000 Message-ID: References: <1c1789ba-68af-66b7-445c-333f02d89392@posteo.de> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="18253"; mail-complaints-to="usenet@ciao.gmane.io" Cc: guile-user To: mikael@djurfeldt.com Original-X-From: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Wed Aug 11 11:49:14 2021 Return-path: Envelope-to: guile-user@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mDkrJ-0004XK-EU for guile-user@m.gmane-mx.org; Wed, 11 Aug 2021 11:49:13 +0200 Original-Received: from localhost ([::1]:39150 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mDkrH-0002qa-Pg for guile-user@m.gmane-mx.org; Wed, 11 Aug 2021 05:49:11 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:50446) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mDkr5-0002n8-C5 for guile-user@gnu.org; Wed, 11 Aug 2021 05:48:59 -0400 Original-Received: from mout02.posteo.de ([185.67.36.66]:49313) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mDkr2-0004Fz-T3 for guile-user@gnu.org; Wed, 11 Aug 2021 05:48:59 -0400 Original-Received: from submission (posteo.de [89.146.220.130]) by mout02.posteo.de (Postfix) with ESMTPS id 73F30240104 for ; Wed, 11 Aug 2021 11:48:53 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.de; s=2017; t=1628675334; bh=A8FL6q1SKMrjWGUV/U1rXttbVd9noO0rX0mwl9nYFsg=; h=Subject:To:Cc:From:Date:From; b=qGacQIFER6jhbC3ZEDc6KiokVmdQcH9a/VgPU56KpYQ1MPf4KjPpKup5IZBOeYjM+ 21d8TBFkF97AKKZ5Hk56FsGwxt0EVtAEEvv7RVvi1Oy+lPB+8Ap41PGDIS+xLJtUO0 hGTZSEt0vClr7Eeet4kWw3AITbmoGW9Y5sDzvPP56xCy4pcw4HN13vhXWaffJaTcyn +ajjUaSG8Ww5vev7qaXR931MXGRx4NavO2+Bk7fCm4XATRb/pvojtw+FGCsoRabk57 sHoDGBQLbYi4yMkX8iVuiPU1+TSuh+ljYEax19LaURdQ8y1Vm/geIVy7l4mcL3UK0J IRePSdVCPFXcg== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4Gl4lT0KQ3z9rxM; Wed, 11 Aug 2021 11:48:52 +0200 (CEST) In-Reply-To: Content-Language: en-US Received-SPF: pass client-ip=185.67.36.66; envelope-from=zelphirkaltstahl@posteo.de; helo=mout02.posteo.de X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Content-Filtered-By: Mailman/MimeDel 2.1.23 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.23 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-mx.org@gnu.org Original-Sender: "guile-user" Xref: news.gmane.io gmane.lisp.guile.user:17680 Archived-At: Hello Mikael! Thank you, that makes it clearer. Different levels of abstraction and pipes of the OS level are represented as ports in Guile. I think I understand now. I quite like the ports concept with its many uses. Best regards, Zelphir On 8/11/21 5:16 AM, Mikael Djurfeldt wrote: > Hi Zelphir! > > A port is a scheme level concept which represents input and output devices. > > Stdin, stdout and stderr are file descriptors which is an OS level concept. > > A pipe is also an OS level concept. It is a communication stream between two > processes. In the OS, it is represented as a file descriptor once opened. > > The function open-input-pipe creates a child process and opens a pipe from it. > In the OS, the pipe is represented as a file descriptor. This is represented > as a port at the scheme level. > > In Guile, this port also has some extra information: It has a type, #{read > pipe}, and also carries (i believe) some extra information, such as the > process identifier of the child process. > > Best regards, > Mikael > > Den ons 11 aug. 2021 03:14Zelphir Kaltstahl > skrev: > > Hello Guile users, > > I recently came across > 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 > > >. > > 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 > > > 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 = # > ~~~~ > > And here for ports: > > ~~~~ > scheme@(guile-user)> (call-with-output-string >                        (λ (port) >                          (display port))) > #$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 > > > -- repositories: https://notabug.org/ZelphirKaltstahl