* bug#58529: possible doc bug in guile manual
@ 2022-10-14 20:48 George Demmy
2022-10-14 21:04 ` George Demmy
0 siblings, 1 reply; 2+ messages in thread
From: George Demmy @ 2022-10-14 20:48 UTC (permalink / raw)
To: 58529
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:
^ permalink raw reply [flat|nested] 2+ messages in thread
* bug#58529: possible doc bug in guile manual
2022-10-14 20:48 bug#58529: possible doc bug in guile manual George Demmy
@ 2022-10-14 21:04 ` George Demmy
0 siblings, 0 replies; 2+ messages in thread
From: George Demmy @ 2022-10-14 21:04 UTC (permalink / raw)
To: 58529
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:
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-10-14 21:04 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-14 20:48 bug#58529: possible doc bug in guile manual George Demmy
2022-10-14 21:04 ` George Demmy
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).