From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Mikael Djurfeldt Newsgroups: gmane.lisp.guile.user Subject: Re: Difference between pipes and ports Date: Wed, 11 Aug 2021 05:16:40 +0200 Message-ID: References: <1c1789ba-68af-66b7-445c-333f02d89392@posteo.de> Reply-To: mikael@djurfeldt.com Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="17658"; mail-complaints-to="usenet@ciao.gmane.io" Cc: guile-user To: Zelphir Kaltstahl Original-X-From: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Wed Aug 11 05:17:13 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 1mDejx-0004Nl-DR for guile-user@m.gmane-mx.org; Wed, 11 Aug 2021 05:17:13 +0200 Original-Received: from localhost ([::1]:53894 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mDejv-0001vI-N8 for guile-user@m.gmane-mx.org; Tue, 10 Aug 2021 23:17:11 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:43786) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mDejg-0001v7-NL for guile-user@gnu.org; Tue, 10 Aug 2021 23:16:56 -0400 Original-Received: from mail-vs1-f42.google.com ([209.85.217.42]:37873) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mDeje-00056l-D4 for guile-user@gnu.org; Tue, 10 Aug 2021 23:16:56 -0400 Original-Received: by mail-vs1-f42.google.com with SMTP id a8so618613vsl.4 for ; Tue, 10 Aug 2021 20:16:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:reply-to :from:date:message-id:subject:to:cc; bh=XRH8RRpQ83tA+RGT2odbI+maz59mXvJeB6PRUUQezJU=; b=q5N11qpODR9Btz15r5/nw0MyQcfumg9gablFQQH5ifa5TflkQv7x0Br7NahoZcfKPH I+cAzHp+/9ItXHk3b4BO1IQODntJwR+GsI3cfhzfX+xraOiSO67jyflcCHsXKE0EbhO2 ZHGUk3kDPj7XESMyHe0gTVBKUIl7f3v1uF29ds6RAKGu5+1Qq+7xeb00HsfmfXWm+U+J 7373s0kRvybMWuLu0YxIsxHa6rXvY+rw/mBzJaaSao69cGgYXcyfUvqD0jaJCoLeJuJ3 1WFopdW/ePdh9BkrszBJ6XlEZBFy+CyguLoZpqC/hrshpOoiOeibCnWFOWJH2lNmE14P hl8w== X-Gm-Message-State: AOAM530spDktIbAa+M0VLuFxdjD/8K0Ei8vxBv5TNl9slzT78xSSIITB 4ls/A/Ku0eq91ohtEE7hzNnfEzAKaQtWNSHj9n4= X-Google-Smtp-Source: ABdhPJyJjPKAtZbGypggAviDzfIkGy114JDcbdWIikSCYMQJF6fjuise7PanFcq0M5wQesuGU10qj/4jCQjEZ2FgV30= X-Received: by 2002:a67:a24f:: with SMTP id t15mr24578268vsh.25.1628651812592; Tue, 10 Aug 2021 20:16:52 -0700 (PDT) In-Reply-To: <1c1789ba-68af-66b7-445c-333f02d89392@posteo.de> Received-SPF: pass client-ip=209.85.217.42; envelope-from=mdjurfeldt@gmail.com; helo=mail-vs1-f42.google.com X-Spam_score_int: -13 X-Spam_score: -1.4 X-Spam_bar: - X-Spam_report: (-1.4 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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:17679 Archived-At: 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-outp= ut/stdout-stderr.scm > < > https://notabug.org/ZelphirKaltstahl/guile-examples/src/master/input-outp= ut/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 =3D # > ~~~~ > > And here for ports: > > ~~~~ > scheme@(guile-user)> (call-with-output-string > (=CE=BB (port) > (display port))) > #$6 =3D "" > ~~~~ > > 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 referenc= e > manual? > > Best regards, > Zelphir > > -- > repositories: https://notabug.org/ZelphirKaltstahl > > >