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: Guile ports Date: Mon, 28 Dec 2020 08:33:25 +0100 Message-ID: <58e8f409-2a26-2384-2b2d-79bc0a622a27@posteo.de> References: <87czyvuz3w.fsf@gnu.org> <87k0t3thsw.fsf@gnu.org> <8735zqfmte.fsf@web.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="18764"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 To: guile-user@gnu.org Original-X-From: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Mon Dec 28 08:43:03 2020 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 1ktnBG-0004ni-Vl for guile-user@m.gmane-mx.org; Mon, 28 Dec 2020 08:43:02 +0100 Original-Received: from localhost ([::1]:42122 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ktnBG-0004Rw-04 for guile-user@m.gmane-mx.org; Mon, 28 Dec 2020 02:43:02 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:50226) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ktn26-0005EY-4l for guile-user@gnu.org; Mon, 28 Dec 2020 02:33:34 -0500 Original-Received: from mout02.posteo.de ([185.67.36.66]:54517) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ktn21-00028L-KZ for guile-user@gnu.org; Mon, 28 Dec 2020 02:33:33 -0500 Original-Received: from submission (posteo.de [89.146.220.130]) by mout02.posteo.de (Postfix) with ESMTPS id 23DFC2400FB for ; Mon, 28 Dec 2020 08:33:25 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.de; s=2017; t=1609140806; bh=Yd4UhBdlNwDyu6O41tTiY/77IGDyOEtlGC5NIBrjsH8=; h=Subject:To:From:Date:From; b=YuW53+QuWk1xLfRJQujd9dGixNPQPtadGhM31rujdGi1qE7VGa+qFW/IkaxzmBjYv Kxlbn3ThrXxScSOL1y0cFaK+aBstMOSsUtRuWomiSSPwUfwk7dMjSnCVtQ/YIEXghw WULXwvQNLJdVsG3C0G2lXn29uRkx0Mueq/D/Ew/ostaT2cj1nGV5+d0w4kizU+AezX XMdSffQlqFZgD9Bh7TWLPgJOrs/VWwzAH6YLORaiZOCbJOY7AXI817/yxMhdWD2qVV SBOiXC6xMWXUIzb/GsAKnwXW7nG7zTCdIHTqRfbTTD1ke2eKD7RiDBQjVcJq+G/ZHH 5Imfur2DeWoNQ== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4D48RT4XG8z6tmB for ; Mon, 28 Dec 2020 08:33:25 +0100 (CET) X-Tagtoolbar-Keys: D20201228083324969 In-Reply-To: <8735zqfmte.fsf@web.de> 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: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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:17127 Archived-At: On that note, I would like to mention, how elegant I find Guile's port system. You know, the whole "write to port to write to a file", "write to a string port" (for example when you want to avoid building many temporary in-between strings), "reading from ports", etc.. I've not seen something like this in other languages yet. Not sure how much of it is Scheme standards, but I like it. It composes quite well, at least on the surface, when you write procedures. You can always accept an optional or keyword argument, which is the port and then leave the choice of what that port is to the caller. It seems more elegant than a file handle or a location of a file or something like that in some other programming languages, where I wanted something similar. At the beginning it was a little confusing to me, as I had not the understanding of what a port is in Guile (and perhaps my understanding is still superficial, but at least working), but now I enjoy it. On 12/28/20 7:48 AM, Dr. Arne Babenhauserheide wrote: > Hi Ludo, > > that’s pretty cool! Thank you! > > Looking at the readme I get the feeling that two little helpers could be > useful: > > (call-with-zstd-output-file "compressed.zstd" > (lambda (port) > (define data > ;; Read the input file in memory. > (call-with-input-file "input-file.txt" > get-bytevector-all)) > > ;; Write data to PORT. > (put-bytevector port data))) > > (call-with-zstd-input-file "compressed.zst" > (lambda (port) > ;; Read decompressed data from PORT. > ...)) > > Potentially with streaming added (if that’s possible from the library): > > (call-with-zstd-output-file "compressed.zstd" > (lambda (outport) > (call-with-input-file "input-file.txt" > (lambda (inport) > (let loop ((data (get-bytevector-some inport))) > (when (not (eof-object? data)) > (put-bytevector outport data) > (loop (get-bytevector-some inport)))))))) > > Also maybe a minimal representation of the commandline-interface: > > (zstd-compress "input-file.txt" #:output "compressed.zst") > (zstd-decompress "compressed.zstd" #:output "cleartext-file.zst") > > Best wishes, > Arne > > Ludovic Courtès writes: > >> Ludovic Courtès skribis: >> >>> I’m pleased to announce the first release of Guile-zstd: >> Oops, a file was missing from the repo, so here’s a brand new release! >> >> git clone https://notabug.org/guile-zstd/guile-zstd >> cd guile-zstd >> git checkout v0.1.1 # or f853c8eb81088f8fbf33d38e62cddea9a4984180 >> git tag -v v0.1.1 >> >> Ludo’. > -- repositories: https://notabug.org/ZelphirKaltstahl