From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: =?UTF-8?Q?Linus_Bj=C3=B6rnstam?= Newsgroups: gmane.lisp.guile.user Subject: Re: Srfi-159/166 - monadic formatting for guile Date: Tue, 18 Jun 2019 12:39:34 +0200 Message-ID: <6ea01089-381f-4ab9-a221-171b9eb1dee8@www.fastmail.com> References: <87pnnj7pd9.fsf@netris.org> <87wohm2g1k.fsf@netris.org> <87r27tuy4g.fsf@netris.org> Mime-Version: 1.0 Content-Type: text/plain;charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="139370"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Cyrus-JMAP/3.1.6-666-gb2312fa-fmstable-20190614v4 To: guile-user Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Tue Jun 18 12:40:40 2019 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1hdBXc-000a78-6L for guile-user@m.gmane.org; Tue, 18 Jun 2019 12:40:40 +0200 Original-Received: from localhost ([::1]:55500 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hdBXa-0003vP-TI for guile-user@m.gmane.org; Tue, 18 Jun 2019 06:40:39 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:36141) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hdBWY-0003vB-6q for guile-user@gnu.org; Tue, 18 Jun 2019 06:39:35 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hdBWW-0005mR-Nk for guile-user@gnu.org; Tue, 18 Jun 2019 06:39:34 -0400 Original-Received: from out3-smtp.messagingengine.com ([66.111.4.27]:59599) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hdBWU-0005h2-9T for guile-user@gnu.org; Tue, 18 Jun 2019 06:39:31 -0400 Original-Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 7AF2422404 for ; Tue, 18 Jun 2019 06:39:27 -0400 (EDT) Original-Received: from imap1 ([10.202.2.51]) by compute1.internal (MEProxy); Tue, 18 Jun 2019 06:39:27 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastmail.se; h= mime-version:message-id:in-reply-to:references:date:from:to :subject:content-type:content-transfer-encoding; s=fm3; bh=5WWvB X5T9S7Im5Q2a2tpeuR+pfXi/FoerS4/uVUnlpg=; b=i+NQGdAR5/Re63HYhjsS7 aEQ/KpSqhoQ+ZSjvk7WPvswreS+3GxBJWrcuIN0jv3wLn4M/iLeU+qi3OVk3dBlE V8x8L9rR4oRp1AyhryBOHk9Pn2rxCHhVuD90x27RIr2YXIdtF4hcHHwl8zoOs+Bi IFoCpkKuhdlM5iVY0znT1u6g9mCZ3Adfy2Ss/1nrRSRzMZXSLvxRiqtKQzbdK+3G EN70YH3ceGyEIuoVgXYJZN16/PHb38HKY7biarK4Z9Eoph4fcGBJWTpbF+wkr605 cmZ4LfV/25QBzOrx3RTwf9GWp4wyc6pPlLkaw6Iz107ABCElA5zNVWTuUWzR+MmJ A== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; bh=5WWvBX5T9S7Im5Q2a2tpeuR+pfXi/FoerS4/uVUnl pg=; b=oq/2Vdn5+0g1Tq4VGvmUDZ4/BG17tKpmAFfTYxZHwuiaK93Jdb+FL3n1P aFtktb0PsjVQEn+5kTNEkLaTR3pvLddXlEC72ZEfpBSLsF/FPB/x2TFOiIFhaW4x FjrOEzo8vU4yTGpsiOdsLTvTycPO2sXmAZ8jU7bRqn5FQMby2TATj8ml3IaW7yLq FZ9w9X+HwkVVs/0Wh/ruGcKrwEd8WQYRMU86reSqvf5jhVV/4OO+aG+VBniFNztE uSb4sUFMv4nYd8uQrLmgPbMJwDQaSBH5AQp67WgWxcMjefRhbDy6EjZvLP20WXZq HuD3bAWHtYCYiXSIig7zBigrakykg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduuddrudeiledgudefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefofgggkfgjfhffhffvufgtgfesth hqredtreerjeenucfhrhhomhepnfhinhhushgpuehjnphrnhhsthgrmhcuoehlihhnuhhs rdhinhhtvghrnhgvthesfhgrshhtmhgrihhlrdhsvgeqnecurfgrrhgrmhepmhgrihhlfh hrohhmpehlihhnuhhsrdhinhhtvghrnhgvthesfhgrshhtmhgrihhlrdhsvgenucevlhhu shhtvghrufhiiigvpedt X-ME-Proxy: Original-Received: by mailuser.nyi.internal (Postfix, from userid 501) id 1F07DC200A3; Tue, 18 Jun 2019 06:39:27 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface In-Reply-To: <87r27tuy4g.fsf@netris.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 66.111.4.27 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.org@gnu.org Original-Sender: "guile-user" Xref: news.gmane.org gmane.lisp.guile.user:15578 Archived-At: So, I have had a look and played around with trimmed/lazy and it does no= thing fancy. It relies solely on guiles own procedures for custom printe= rs, which means we get guile's guarrantees for free. Recursive records a= re no problem, nor are circular lists of any rank or vectors any problem= . trimmed/lazy is also well-behaved when printing circular lists/vectors. = (show #t (trimmed/lazy 100 (each-in-list (circular-list 1 2 3 4)))) work= s just fine and displays 1 2 3 4 ... until the 100 character limit is me= t. I will have to do some porting to delimited continuations or CPS because= currently it is relying on call/cc and the overhead is quite noticeable= . --=20 Linus Bj=C3=B6rnstam On Sun, 16 Jun 2019, at 21:35, Mark H Weaver wrote: > Hi John, >=20 > John Cowan writes: >=20 > > On Sun, Jun 16, 2019 at 2:47 AM Mark H Weaver wrote= : > > > > > >> How do you implement 'written-shared', 'pretty-shared', and > >> 'trimmed/lazy'? In particular, how do you avoid non-termination wh= en > >> asked to print cyclic data, when the cycle includes a non-standard = data > >> type printed using a custom printer? For example, what if you prin= t a > >> list that includes an object whose custom printer will print output= that > >> includes the same list that you started with? > >> > > > > Of course it can't cope with that. But consider an object whose cus= tom > > printer outputs its instance variables where one of those instance v= ariables > > has been assigned to the object itself. No procedure other than the= object > > printer itself is going to be able to break *that* loop. >=20 > The built-in 'write' and 'display' procedures can break the loop, whic= h > is the approach that I chose when I last looked at this. >=20 > Regards, > Mark >=20 >