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: Naming help for a looping facility Date: Sat, 6 Mar 2021 17:58:15 +0100 Message-ID: References: <4d26504a-cab5-4112-92a1-745aed06671e@www.fastmail.com> 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="27183"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.1 To: guile-user@gnu.org Original-X-From: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Sat Mar 06 17:58:41 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 1lIaGH-0006z7-9Z for guile-user@m.gmane-mx.org; Sat, 06 Mar 2021 17:58:41 +0100 Original-Received: from localhost ([::1]:43328 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lIaGG-0005AO-Ca for guile-user@m.gmane-mx.org; Sat, 06 Mar 2021 11:58:40 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:44298) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lIaG1-0005A5-J7 for guile-user@gnu.org; Sat, 06 Mar 2021 11:58:25 -0500 Original-Received: from mout02.posteo.de ([185.67.36.66]:60867) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lIaFw-00042p-JO for guile-user@gnu.org; Sat, 06 Mar 2021 11:58:25 -0500 Original-Received: from submission (posteo.de [89.146.220.130]) by mout02.posteo.de (Postfix) with ESMTPS id B88722400FB for ; Sat, 6 Mar 2021 17:58:16 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.de; s=2017; t=1615049896; bh=GuBFHMZx49FksuPmQcy/V4+iSuX8IyXbN5V84F5tC2o=; h=Subject:To:From:Date:From; b=IT1muPvjwNC0aUGe/W+5cxgCVdnLYn1PxNmJr0hx6TYtu+duCznXFEyATkl2Mc3ak SKosaGq9BaBH7yMCzP65vEhQDZgKug256fPgNqi0tcYCs/YxtVoJJzvyKKSjHqobau P/dVvpCR0tR75NYyneZsVicbt9czKSUNN2zE1b2aKyJUWCKz/HhYORwaqBl58DreeV 4+UkMAY5PMOdbEzokw73bP+hJ86yBpdb48VQKwb5hJ7yhO2ciLt6cqlo/qCkAWqOHP m1aeLha0Enrb948M42KCDc4CyWViE7kqXlk3ImUGwtD2oOTmkuhyjBEI0+et/7E4zt 1soiaKcz5/l5w== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4Dt9lr0vQ4z6tmL for ; Sat, 6 Mar 2021 17:58:15 +0100 (CET) In-Reply-To: <4d26504a-cab5-4112-92a1-745aed06671e@www.fastmail.com> 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, NICE_REPLY_A=-0.001, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, 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:17345 Archived-At: Hello Linus! Not sure my idea for naming is any good: Perhaps you could use the word "iteration" or "iter" in combination with something else. I have a bit of difficulty understanding how these forms work. The readme could perhaps be better, if you showed the output as well as describing it, which you already do and show multiple examples per form, varying the arguments. For example: ~~~~ (define lst '((1 2) dud (3 4) (5 6))) (loop ((:for a (in-list lst)) (:when (pair? a)) (:for b (in-list a)) (:acc acc (summing b))) => acc) ~~~~ What happens, if one leaves the :when away? Is it strictly necessary, when we already use in-list, telling the machine, that we are processing a list? What changes, when we put :subloop in there? I am guessing, that it is the difference between nested looping and not nested. In the example with :subloop, you have shown the output. If comparing to Racket's for-loop variants, I could imagine, that it could improve understanding, if you put the Racket expression there and then show how to do the same with the forms you are showing. Would your implementation be portable between various Schemes? That would be great! One problem I had when migrating my decision tree implementation from Racket to GNU Guile was, that I had been using Racket's special for-loop forms and that I had to translate those back into named let or others, to get it running on GNU Guile. If one could simply load your library in any Scheme that fulfills some known and specified set of conditions, one would not need to worry about portability of the code as much. Best wishes, Zelphir On 3/5/21 9:58 PM, Linus Björnstam wrote: > Hello fellow guilers! > > I have been writing the bastard child of foof-loop/chibi loop (https://mumble.net/~campbell/darcs/hack-foof-loop/foof-loop.txt) and racket's for loops. The current pre-beta can be found here: https://git.sr.ht/~bjoli/goof-loop/ > > I want to, just like the racket loops, provide simple forms, so that I instead of > > (loop ((:for a (up-from 0 10)) (:acc acc (listing (* a a)))) => acc) > > can write > > (NAME ((:for a (up-from 0 10))) (* a a)). > > My struggle is what I should name this. In racket it is for/list. I could of course call it loop/list, but that is inconsistent with the naming inherited from (chibi loop): listing. loop/listing becomes verbose (it's scheme after all) and is very clear what it does. But, as I already have a listing macro to be used within the loop facility, wouldn't (listing ((:for a (up-from 0 10)) ...) be a good name? Is it too magical? > > I happen to think that it is elegant, but I don't know. It doesn't feel like the scheme way. I am pretty sure I want a special form for these things, as it allows for some optimization work. listing, as we all understand, has to reverse it's arguments, whereas a special form easily can rewrite itself to be a non-tail-recursive loop (which is faster than a reverse, yet without all the nasty sides of reverse!) > > The options as of right now: > > (loop/list ...) > Upsides: > - pretty short > - loop/list works differently from listing, even tthough the end result is the same. This signals that to some extent. > - If I am stealing from racket anyway... > Downsides: > - not as clear as (loop/listing ...). To be honest, this is a pretty big one. If I _could_ I would make (loop (... ( ...(listing ...))) ...) work like the simple form, but that is not possible if we have other accumulating clauses. > > (loop/listing ...) > Upsides: > - The most clear > Downsides: > - Verbose, which is what we want to avoid. > > (listing ...) > Upsides: > - We export fewer identifiers > - Is already used as an accumulating clause > - shortest > Downsides: > - Too much magic? > - One exported form does two related, but different things in different contexts? > - (anding ...) makes sense, whereas (loop (... (:acc a (anding ...))) ...) does almost not at all. > > I somewhat prefer the last one, but it feels icky. So, scheme sages of guile-user, what do you say? > > Liebe Grüße > Linus Björnstam > -- repositories: https://notabug.org/ZelphirKaltstahl