From: Maxim Cournoyer <maxim.cournoyer@gmail.com>
To: Arne Babenhauserheide <arne_bab@web.de>
Cc: 36682@debbugs.gnu.org, Hans-Werner Roitzsch <hwroitzsch@posteo.net>
Subject: bug#36682: Error in Guile scripting examples
Date: Mon, 12 Dec 2022 20:08:28 -0500 [thread overview]
Message-ID: <87zgbs3yb7.fsf@gmail.com> (raw)
In-Reply-To: <875yeg5njw.fsf@gmail.com> (Maxim Cournoyer's message of "Mon, 12 Dec 2022 16:17:55 -0500")
Hi,
Maxim Cournoyer <maxim.cournoyer@gmail.com> writes:
[...]
> I have the following two files:
>
> fact:
>
> #!/run/current-system/profile/bin/guile \
> -e main -s
> !#
> (define-module (fact)
> #:export (fact))
>
> (define (fact n)
> (if (zero? n) 1
> (* n (fact (- n 1)))))
>
> (define (main args)
> (display (fact (string->number (cadr args))))
> (newline))
>
>
> fac:
>
> #!/run/current-system/profile/bin/guile \
> -e (@@ (fac) main) -s
> !#
> (define-module (fac)
> #:export (main))
>
> (use-modules (fact))
>
> (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)))
>
>
> But with Guile 3.0.8, this gives me:
>
> ./fac 5 20
> ice-9/read.scm:126:4: In procedure lp:
> #<unknown port>:1:4: unexpected end of input while searching for: )
>
> Which I don't understand.
OK, so what is apparently problematic with modules is the use of '-e (@@
(module-name) proc-name)' with Guil modules. For the 'fac' file above,
modifying it like this:
--8<---------------cut here---------------start------------->8---
#!/run/current-system/profile/bin/guile \
-e (fac) -s
!#
(define-module (fac)
#:export (main))
(use-modules (fact))
(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)))
--8<---------------cut here---------------end--------------->8---
works. This relies on 'main' being defined and public. I hope that
helps!
--
Thanks,
Maxim
prev parent reply other threads:[~2022-12-13 1:08 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-15 22:39 bug#36682: Error in Guile scripting examples Hans-Werner Roitzsch
2019-07-15 23:44 ` Arne Babenhauserheide
2022-12-12 21:17 ` Maxim Cournoyer
2022-12-13 1:08 ` Maxim Cournoyer [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=87zgbs3yb7.fsf@gmail.com \
--to=maxim.cournoyer@gmail.com \
--cc=36682@debbugs.gnu.org \
--cc=arne_bab@web.de \
--cc=hwroitzsch@posteo.net \
/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).