From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: "Thompson, David" Newsgroups: gmane.lisp.guile.user Subject: Re: unusual let binding (of lp) - in function element->xml from sxml simple Date: Sat, 3 Feb 2024 16:55:29 -0500 Message-ID: References: <87zfwhrzcq.fsf@softland> 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="20378"; mail-complaints-to="usenet@ciao.gmane.io" Cc: guile-user To: Andreas Reuleaux Original-X-From: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Sat Feb 03 22:56:10 2024 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 1rWNze-00055E-Am for guile-user@m.gmane-mx.org; Sat, 03 Feb 2024 22:56:10 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rWNzI-0000CM-Qg; Sat, 03 Feb 2024 16:55:49 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rWNzF-0000CB-UL for guile-user@gnu.org; Sat, 03 Feb 2024 16:55:46 -0500 Original-Received: from mail-yw1-x1133.google.com ([2607:f8b0:4864:20::1133]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rWNzE-000462-2G for guile-user@gnu.org; Sat, 03 Feb 2024 16:55:45 -0500 Original-Received: by mail-yw1-x1133.google.com with SMTP id 00721157ae682-6040d33380cso33100007b3.1 for ; Sat, 03 Feb 2024 13:55:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=worcester-edu.20230601.gappssmtp.com; s=20230601; t=1706997341; x=1707602141; darn=gnu.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=JzDfrSllXGW/XsRyCXs8IN9VkvZ72mSwPq6/f2R3E0A=; b=F+ooO0IdFXLWqbc3s1Skl/SU6QylJQz+/RJj/h1DqncKlcA6WB/TxPAX0IW+kJOdIC TjSLGnVcVqAYb/MwQp7fLVf0ZY885M3kzv7dItSKzXGN7mTeIQDPuGbNiK8/6Zpsl8In Rtb1h/X+wrtD256R1XnK8x17vuLdnu2mAsf0H2YoA5yNIQfTE+HY8SexbeEu8AeyiJS9 LsnRgPFXHPqOjRDkEhfVT6V8CLBSJtjH0lkadr9qAo5aYQ5ziB6Jt7AvKkdOM5SBICu9 SRYQBcgFH/gWvKpkB1gc5xcnOkkNEukSeT8kyeN4tI9TL1v0SrUT+JvqUIF4WA3fTqeF xttQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706997341; x=1707602141; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=JzDfrSllXGW/XsRyCXs8IN9VkvZ72mSwPq6/f2R3E0A=; b=vX+HGHmABHKRRketPW/txuTWIrt27PTVPDZXK/I2Jydb8ezimOYzAoDaKyqIlPdQZ7 URrXe4IGbwgAZ6GQGNo2JOvMhpFMq0BU53PRXu914LY5bsw7o5DRNFHOXsjF8KZzi+Dk kHRYEzsrSF8hwNf+E2wea0VZeFLwpWIrvWSsma8Ppw8/hchSbI0wKn6XuNAQsN7Uq6Dx EiFHHX0rKjngTjHHaPCZ1Uj66xsfJxXuHqY9mzvSNBhoV9pHvJvd//V2nCbjWymoxmf0 0TqyggbuuspDyDCCiUHA8zgFWXM6Ojl83im/4bkndmPFyB25AvzrLpXWyN6iqetCPRjh 6sAg== X-Gm-Message-State: AOJu0Yz2SBjI4OYl4Ly+l1gKajvHXQj5qNfy/Z4vQTvoR3byrOFCMqJt zNG1gS75sbL/5ECNFGmiPO/a7F4V/Ti65H9Jt/peRrrVb1BUZanZi0Pj3nbeKAN+1L04XhOHYq9 oIfYXz5TO54OY2LWgB6g/ZVRhIbSfjMZVPL71KN/p+kpgw6NP X-Google-Smtp-Source: AGHT+IF5FVfG4LOtbSj6foI1xia8++cg9V7k8SmDBTT8cDjcVVpFyYwMtdwxA9gLpWXOP14t28yTxXoxMkglQKdWra0= X-Received: by 2002:a81:4e48:0:b0:5ff:5e94:277b with SMTP id c69-20020a814e48000000b005ff5e94277bmr6278444ywb.45.1706997341246; Sat, 03 Feb 2024 13:55:41 -0800 (PST) In-Reply-To: <87zfwhrzcq.fsf@softland> Received-SPF: pass client-ip=2607:f8b0:4864:20::1133; envelope-from=dthompson2@worcester.edu; helo=mail-yw1-x1133.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.29 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-bounces+guile-user=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.lisp.guile.user:19432 Archived-At: Hi Andreas, On Sat, Feb 3, 2024 at 4:49=E2=80=AFPM Andreas Reuleaux wrot= e: > sxml->xml making use of element->xml above. > Now with regards to the binding / usage of lp above: it is > bound / used several times: > > > (let lp ((attrs attrs)) ... > let lp be a function that ... does what? > > > (lp (cdr attrs))) > now call this function with (cdr attrs). > What does it do? > set attrs to (cdr attrs)? > > > then similar below > (let lp ((body body)) ... > ??? > > > (lp (cdr body))) > ??? > > > For one thing I am used to > > (let bindings body) > > with bindings being of the form > ((x 'foo) > (y 'bar)) > > (i.e. bind x with 'foo, y with 'bar when executing body) > > for example, lp is not of this style. Maybe if there is just one variable= bound > one can shortcut this to > > let x 'foo body > > Is this what's going on above? And if so: > then lp is bound to a list of one pair? : > > ((attrs attrs)) > > how come can we call this as a function then later. > > And if attrs is a function (which I doubt) that what > is the application of attrs to attrs? This is a form of 'let' known as "named let". In the code you reference, the variable 'lp' is a procedure, short for "loop", and the let bindings give initial values for the loop. Calling 'lp' will bring control back to the beginning of the 'let' with the bindings rebound to new values. It's a convenient shorthand for simple loops. See https://www.gnu.org/software/guile/manual/html_node/while-do.html#index= -let-1 for more info. Hope this helps, - Dave