From: "Thompson, David" <dthompson2@worcester.edu>
To: Andreas Reuleaux <rx@a-rx.info>
Cc: guile-user <guile-user@gnu.org>
Subject: Re: unusual let binding (of lp) - in function element->xml from sxml simple
Date: Sat, 3 Feb 2024 16:55:29 -0500 [thread overview]
Message-ID: <CAJ=RwfbQqJyr9aeE7rSSW6N_NBD47wuGPo6xEt=Mspm2hYU4vw@mail.gmail.com> (raw)
In-Reply-To: <87zfwhrzcq.fsf@softland>
Hi Andreas,
On Sat, Feb 3, 2024 at 4:49 PM Andreas Reuleaux <rx@a-rx.info> wrote:
> 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
next prev parent reply other threads:[~2024-02-03 21:55 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-03 21:51 unusual let binding (of lp) - in function element->xml from sxml simple Andreas Reuleaux
2024-02-03 21:55 ` Thompson, David [this message]
2024-02-03 22:16 ` Andreas Reuleaux
2024-02-04 6:30 ` tomas
2024-02-04 8:46 ` Damien Mattei
2024-02-04 15:37 ` Andreas Reuleaux
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAJ=RwfbQqJyr9aeE7rSSW6N_NBD47wuGPo6xEt=Mspm2hYU4vw@mail.gmail.com' \
--to=dthompson2@worcester.edu \
--cc=guile-user@gnu.org \
--cc=rx@a-rx.info \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).