From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: =?UTF-8?Q?Linus_Bj=C3=B6rnstam?= Newsgroups: gmane.lisp.guile.user Subject: Re: Announcing the first actually stable release of guile-for-loops Date: Fri, 24 Jan 2020 22:02:54 +0100 Message-ID: References: <8736c546c9.fsf@web.de> Mime-Version: 1.0 Content-Type: text/plain;charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="37308"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Cyrus-JMAP/3.1.7-777-gdb93371-fmstable-20200123v1 To: "Arne Babenhauserheide" , guile-user@gnu.org Original-X-From: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Fri Jan 24 22:03:57 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 1iv67Q-0009f5-Rf for guile-user@m.gmane-mx.org; Fri, 24 Jan 2020 22:03:57 +0100 Original-Received: from localhost ([::1]:48062 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iv67P-0001wn-KS for guile-user@m.gmane-mx.org; Fri, 24 Jan 2020 16:03:55 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:50195) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iv66v-0001wc-9y for guile-user@gnu.org; Fri, 24 Jan 2020 16:03:26 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iv66t-0004UA-S3 for guile-user@gnu.org; Fri, 24 Jan 2020 16:03:25 -0500 Original-Received: from wout5-smtp.messagingengine.com ([64.147.123.21]:45083) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iv66t-0003xW-FW for guile-user@gnu.org; Fri, 24 Jan 2020 16:03:23 -0500 Original-Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id 15B2D9CF; Fri, 24 Jan 2020 16:03:16 -0500 (EST) Original-Received: from imap1 ([10.202.2.51]) by compute1.internal (MEProxy); Fri, 24 Jan 2020 16:03:16 -0500 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=fm2; bh=g0LWD hxI9fIJJC4ZCg4X5aGysY4zannT9kkxS1soEaA=; b=kGZ0pQfHQJMEHRTYbVBO9 IF9YVnnc6NKH2N8XUq0x+AQ+Wh/T1Ca2hnhPrWn7x4oJ6xW15cB0X1+s8g1Z9rtl 0IV6NNbkC1k7t7SbabnyLqJ2AhOnVMzjkItj4Wky7krcj47wIt4ycnaw77GJbthX UPw5nvw2NkZn1NfEia3yqOSnyDBTdcJaF3o8G9uqVZL0lU/htukSWt2ktGHw241C w+aA3REcNPlHF3j2pfRifVc8+dh3nCz681rXhqDomaEl0l2vn/E+EExfA1I8bdwB UxQLXwSmc4ZXXLaQhwX1r0ypKeGF9XIbrr4G8XI+nghaoWoip0s5BfYQ73DNYqKq g== 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=fm1; bh=g0LWDhxI9fIJJC4ZCg4X5aGysY4zannT9kkxS1soE aA=; b=ZKJ/4zqb+hVsCgNQuSr/yZIJNIPZ7I1iaDKKhw0vLmfSCyvSyMQuDIWzv 3aWwXPeGOrrPH4z6U8esEeEGFIOBAFID2WiPz6nyf8NerJLw5UVuZ8GVIimwypSt usuEbUPMd8nmQSIj8MDcVt61lDT7T/Qt6uGzhZx9utEFkbYC2drYWYKaoDZPN3qB bRLy0f4JjDBfHt9/483nBz/da+6UDPrEwgr1sm0NWYdVCJSKvYHY8IiOmJeJdftV E1bwetlKgrvJ5D4f8bNycdaUYgqpuzI/xJZfCTmT2YA00cEdCyuoMnn/3CqKAoOD xhf7p0muWhKYG88RTRtBJiDxegkeQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedugedrvdehgddutdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefofgggkfgjfhffhffvufgtgfesthhqredtreerjeenucfhrhhomhepnfhinhhu shgpuehjnphrnhhsthgrmhcuoehlihhnuhhsrdhinhhtvghrnhgvthesfhgrshhtmhgrih hlrdhsvgeqnecuffhomhgrihhnpehsrhdrhhhtnecuvehluhhsthgvrhfuihiivgeptden ucfrrghrrghmpehmrghilhhfrhhomheplhhinhhushdrihhnthgvrhhnvghtsehfrghsth hmrghilhdrshgv X-ME-Proxy: Original-Received: by mailuser.nyi.internal (Postfix, from userid 501) id 3C52EC200A5; Fri, 24 Jan 2020 16:03:15 -0500 (EST) X-Mailer: MessagingEngine.com Webmail Interface In-Reply-To: <8736c546c9.fsf@web.de> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 64.147.123.21 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:16093 Archived-At: On Fri, 24 Jan 2020, at 09:16, Arne Babenhauserheide wrote: > Hi, >=20 > Linus Bj=C3=B6rnstam writes: > > The syntax is more or less the same as racket's loops, and they are = generally compatible. The code generated is for almost all cases as fast= as hand-rolled code. They are all expressed as left or right folds, and= are as such (apart from for/list, but read about that in the documentat= ion) free of mutation. They are all converted to named lets. >=20 > That=E2=80=99s cool! >=20 > > (define (erathostenes n) > > (define vec (make-vector n #t)) > > (for/list ([i (in-range 2 n)] #:when (vector-ref vec i)) > > (for ([j (in-range/incr (* 2 i) n i)]) > > (vector-set! vec j #f)) > > i)) > > > > The code and documentation is available here: > > https://hg.sr.ht/~bjoli/guile-for-loops >=20 > Is there a chance that this could get included in Guile (ice-9 > for-loops?) and become a SRFI? John Cowan asked me to write a SRFI, but right now I don't think it is r= eally in good enough shape to be a srfi. The for/foldr internals is a ca= n of worms. Currently I am planning on removing the "procedural" part of= that (stolen from what I saw in the macro expansion of racket's for/fol= dr) and resort to macros generating macros instead (due to otherwise los= ing syntax context information). I could probably trim at least 100 lines of code from the implementation= as it is now. >=20 > If the code is non-portable (I guess the #:keywords are), the two > existing implementations (Racket, Guile) would still be sufficient for= a > SRFI. The code is surprisingly portable as long as you are porting to a syntax= -case scheme! Redefining the keywords as auxiliary syntax made porting a= n earlier version to chez scheme a 2 evening job :) I still had some ann= oying bugs that I didn't want to spend time on, but it shouldn't be hard= . Some of the recent changes to the code was introduced to facilitate po= rting to non-keyword schemes: (in-range a b #:incr c) =3D> (in-range/inc= r a b c), for example. The only downside is that I would have to squat on when:, unless:, final= :, break:, length: and fill:. /Linus