From: George Demmy <gdemmy@gmail.com>
To: 58529@debbugs.gnu.org
Subject: bug#58529: possible doc bug in guile manual
Date: Fri, 14 Oct 2022 16:04:53 -0500 [thread overview]
Message-ID: <CA+7PDU1m0X=k5aMWCfYArpfwj5szfD49RFpJc+EZt-s9=Lfrmw@mail.gmail.com> (raw)
In-Reply-To: <CA+7PDU2_ogrT5yhyFQLu3g8Y5Rte4z2ncXrE8hmQyQRANunXnQ@mail.gmail.com>
Sorry about the fat finger automagic send from gmail...
Reading through the gnu manual, I wanted to get a better handle on
some of @ module syntax introduced in:
https://www.gnu.org/software/guile/manual/html_node/Scripting-Examples.html
I cut and pasted fact and choose into their own files.
I used this version of choose:
#!/usr/bin/env sh
exec guile -l fact -e '(@ (fac) main)' -s "$0" "$@"
!#
(define-module (fac)
#:export (main))
(define (choose n m)
(/ (fact m) (* (fact (- m n)) (fact n))))
(define (main args)
(let ((n (string->number (cadr args)))
(m (string->number (caddr args))))
(display (choose n m))
(newline)))
It was pure cut and paste, no edits save changing /usr/local/bin/guile
to /usr/bin/guile. Running choose I got
./choose:8:6: In procedure main: Unbound variable: fact
I wondered if there was something going on with -l fact, so I changed
the args for choose to:
exec guile -l fact -e main -s "$0" "$@"
and it indeed ran main from fact. Then I changed it to:
exec guile -l fact -e fact -s "$0" "$@"
and it unsurprisingly yielded:
fact:5:6: In procedure fact:
In procedure =: Wrong type argument in position 1: ("./choose.scm" "4")
So, guile is loading fact (the file and its contents), but it seems
that define-module has got something to do with it.
This is guile 3.0.8 on an up-to-date cygwin. You get similar behavior
on guile 2.0.14 on OpenSUSE LEAP 15.3.
Regards,
George Demmy
On Fri, Oct 14, 2022 at 3:48 PM George Demmy <gdemmy@gmail.com> wrote:
>
> Hi,
>
> Reading through the gnu manual, I wanted to get a better handle on
> some of @ module syntax introduced in:
> https://www.gnu.org/software/guile/manual/html_node/Scripting-Examples.html
> I cut and pasted fact and choose into their own files.
>
> I used this version of choose:
prev parent reply other threads:[~2022-10-14 21:04 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-14 20:48 bug#58529: possible doc bug in guile manual George Demmy
2022-10-14 21:04 ` George Demmy [this message]
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='CA+7PDU1m0X=k5aMWCfYArpfwj5szfD49RFpJc+EZt-s9=Lfrmw@mail.gmail.com' \
--to=gdemmy@gmail.com \
--cc=58529@debbugs.gnu.org \
/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).