Received: (at 36682) by debbugs.gnu.org; 13 Dec 2022 01:08:43 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Mon Dec 12 20:08:43 2022 Received: from localhost ([127.0.0.1]:56776 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1p4tmk-0003gQ-NR for submit <at> debbugs.gnu.org; Mon, 12 Dec 2022 20:08:42 -0500 Received: from mail-vs1-f45.google.com ([209.85.217.45]:35388) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <maxim.cournoyer@HIDDEN>) id 1p4tmj-0003gI-Q1 for 36682 <at> debbugs.gnu.org; Mon, 12 Dec 2022 20:08:42 -0500 Received: by mail-vs1-f45.google.com with SMTP id k185so13166681vsc.2 for <36682 <at> debbugs.gnu.org>; Mon, 12 Dec 2022 17:08:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:user-agent:message-id:in-reply-to:date:references :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=qMV3R0R1ClnR1yqo91Ov+sYoIN9Oxi77S4nC0x7Gm3U=; b=c9R9YO7JIs18kjugeB4OmRJJ06jiZGthI79gOwwbhuButZSKFf1HZsNmrs1n2hzUYR 5Ja2UT4Snc6kGzga1mp/CZ4pHXcHd5aaD48YtG0Bus40g3WEKE1Ib518GDUUOn8hhOqF An4vS/hPTYTfgrfY92c+risj0andzfPEW24I6VCrVEN9p13a4JF5lXRnoBjgDtZdaUHy uUT5x+z/FelMilZ2yTy8XniNljwGpi8mFBAl9lmiftyZl1HtRNMKP4ocxhv0oxXbEhKy dbZ44yGDYyHGCUBwgGq6BhkRyGS0Jk58lLX/JG+kwpDg/IYEHdm2AHoPNSkllZjXYPOd ioPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:user-agent:message-id:in-reply-to:date:references :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=qMV3R0R1ClnR1yqo91Ov+sYoIN9Oxi77S4nC0x7Gm3U=; b=w4D1JNAOSyqskb81Z78H5YTU9t1qczMKEYtF0fsWWlhhrJuUKCD5JwKduibbMj/EFd 4pxuuJS3f4MibULUn/BVjTMf4P/1cp0n9Ov28WXukuimct/8AeshHgN4G6K/x4RIXv1A MY35sKPDRPdOSlD1mqIfbRdvnGBgpqhTRJEWGnDhfp20yINo0Mq+lM4yKlu+hI16EsBx fQbvOF34aU/xLF/RJeHa84tpJicKPcMelHMJzsU07//M3jvNzJB3oYc+QsqpvGcbKyJ8 LYw77T9RGeqcv2ql0uLdd+3jJ8OnCVeI8hTbSYqIkQB/nDjujvIgm5O03Erb+FV4MnZy dC3w== X-Gm-Message-State: ANoB5plHafcjKaPfP0LAgnicqtug7omUw80dwedxCR55a1X+N8JiUuNZ jbfu7sSaP3OYsfxQaSEAVsU= X-Google-Smtp-Source: AA0mqf4IkQlqcsdPUnLU6XURnLxUbTVSDjB5JoYTsf/uDV0IjfdU4CduSIZiUfbLj/2it9OPF4hl8g== X-Received: by 2002:a05:6102:151:b0:3b1:29d1:3496 with SMTP id a17-20020a056102015100b003b129d13496mr7977822vsr.27.1670893711361; Mon, 12 Dec 2022 17:08:31 -0800 (PST) Received: from hurd ([2607:fad8:4:3::1006]) by smtp.gmail.com with ESMTPSA id q11-20020a37f70b000000b006faaf6dc55asm6852866qkj.22.2022.12.12.17.08.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Dec 2022 17:08:30 -0800 (PST) From: Maxim Cournoyer <maxim.cournoyer@HIDDEN> To: Arne Babenhauserheide <arne_bab@HIDDEN> Subject: Re: bug#36682: Error in Guile scripting examples References: <6956abda-8d34-8f3a-0816-9faacee7c7e7@HIDDEN> <875zo2g8wo.fsf@HIDDEN> <875yeg5njw.fsf@HIDDEN> Date: Mon, 12 Dec 2022 20:08:28 -0500 In-Reply-To: <875yeg5njw.fsf@HIDDEN> (Maxim Cournoyer's message of "Mon, 12 Dec 2022 16:17:55 -0500") Message-ID: <87zgbs3yb7.fsf@HIDDEN> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 36682 Cc: 36682 <at> debbugs.gnu.org, Hans-Werner Roitzsch <hwroitzsch@HIDDEN> X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) Hi, Maxim Cournoyer <maxim.cournoyer@HIDDEN> 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
bug-guile@HIDDEN
:bug#36682
; Package guile
.
Full text available.Received: (at 36682) by debbugs.gnu.org; 12 Dec 2022 21:18:05 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Mon Dec 12 16:18:05 2022 Received: from localhost ([127.0.0.1]:55435 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1p4qBZ-0004AA-0b for submit <at> debbugs.gnu.org; Mon, 12 Dec 2022 16:18:05 -0500 Received: from mail-yw1-f181.google.com ([209.85.128.181]:37517) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <maxim.cournoyer@HIDDEN>) id 1p4qBX-00049m-8w for 36682 <at> debbugs.gnu.org; Mon, 12 Dec 2022 16:18:03 -0500 Received: by mail-yw1-f181.google.com with SMTP id 00721157ae682-3c090251d59so165555297b3.4 for <36682 <at> debbugs.gnu.org>; Mon, 12 Dec 2022 13:18:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:user-agent:message-id :in-reply-to:date:references:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to; bh=4OO1FxzZzUezzKql/P97VBqRkUkE+P2cQD71wz++oI0=; b=Rvzo5E9qQNHy7Jeh43sxuN5hecgM9YQdEtOt9Pyb2Szt/sVIJDyngrUAKbT8dny+sI 1OmzY0s2Khi31QEAsDz5jy/AhKT1v/h7Fx49bDDYqopC7AGkLS7IaSQUidMTYewTwhrZ osOXVUc20QFnSKaHmmwXWbKnjtdDRoxtIUMgYinRMd8OdiHPCVIg7bTi6h/DTS4dvx13 Ubxb9AHu9GBe2YCDAQEhoilpYDDlUKWScTMOY4rCf3PNTKS7jbMR4+EsbEW9BbLH0XOh n/5ZW1iM9TLM/zoUlze6lL5Z/Gn6vlNl2IgA1LSEcMmMxn0OuuZnXSxzmWB4487dHO7o qC0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:user-agent:message-id :in-reply-to:date:references:subject:cc:to:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=4OO1FxzZzUezzKql/P97VBqRkUkE+P2cQD71wz++oI0=; b=azMjs3iSfZ/DiEH7dTjtK0uI28wLnyukvteV78rAKR/3bo54YAFAYUoz1g0BqHpGvh EoozkwmyJCY/UvvCWOCqUY1zKwLTwsTBua3+/dCaNSGaepACC+ZO08APR+bbwzl3nCbI IXi+G8t84PrRBn74t6Pv7dfZR9xRzOSez5rRS+NlE+73Vv/fsRmhfRLFtk7uzUU2AiIV wxFO6XvpgSY/JFCFXk8s/+NSdAtClWbbOzv0iYM2v0c+oOw5tlQrSUyxiqSAhXXb0MIF FKjHbZgcGySdZlEtlBHP248LHknT6+BTKwoGJLk5moTEgRXCsCv0lChFm8gZSUG3jwfz lo9w== X-Gm-Message-State: ANoB5plTPTEy1C+sjnR3IcwBFIPLxihRsCDohiEbC4SQjafisonMwhJ1 8U08/vbJEaPEqwryqAq8LzKR5KLonk2F6w== X-Google-Smtp-Source: AA0mqf4lDzHHuhrtTWafM7R0bv0Q5m5P+SiQKso4BMXPpKfL5NzgE5uaIvWMqhaLHkWSDF7TCD/UQw== X-Received: by 2002:a81:a8c:0:b0:36f:83d2:e3c9 with SMTP id 134-20020a810a8c000000b0036f83d2e3c9mr13953496ywk.52.1670879877592; Mon, 12 Dec 2022 13:17:57 -0800 (PST) Received: from hurd ([2607:fad8:4:3::1006]) by smtp.gmail.com with ESMTPSA id f1-20020a05620a408100b006ecfb2c86d3sm6365273qko.130.2022.12.12.13.17.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Dec 2022 13:17:56 -0800 (PST) From: Maxim Cournoyer <maxim.cournoyer@HIDDEN> To: Arne Babenhauserheide <arne_bab@HIDDEN> Subject: Re: bug#36682: Error in Guile scripting examples References: <6956abda-8d34-8f3a-0816-9faacee7c7e7@HIDDEN> <875zo2g8wo.fsf@HIDDEN> Date: Mon, 12 Dec 2022 16:17:55 -0500 In-Reply-To: <875zo2g8wo.fsf@HIDDEN> (Arne Babenhauserheide's message of "Tue, 16 Jul 2019 01:44:39 +0200") Message-ID: <875yeg5njw.fsf@HIDDEN> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 36682 Cc: 36682 <at> debbugs.gnu.org, Hans-Werner Roitzsch <hwroitzsch@HIDDEN> X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) Hello, Arne Babenhauserheide <arne_bab@HIDDEN> writes: > Hello Hans-Werner Roitzsch, > > It looks like you=E2=80=99re mixing up two concepts: the fac creates a mo= dule > and loads the fact which is not a module, so basically main and choose > live in another namespace than fact (define-module starts a new > namespace). > > And it seems that this is indeed a bug in the documentation, because > https://www.gnu.org/software/guile/manual/html_node/Scripting-Examples.ht= ml#Scripting-Examples > jumps to defining fac as a module but does not at the same time define > and import fact as a module, too. > > Hans-Werner Roitzsch <hwroitzsch@HIDDEN> writes: >> I have the file `modules.scm` with the following code: >> >> ----8<----start-of-code---->8---- >> #!/usr/bin/env sh >> exec guile -l fact.scm -e '(@ (my-module) main)' -s "$0" "$@" >> !# >> >> ;; Explanation: >> ;; -e (my-module) >> ;; If run as a script run the `my-module` module's `main`. >> ;; (Use `@@` to reference not exported procedures.) >> ;; -s >> ;; Run the script. >> >> (define-module (my-module) >> #:export (main)) > > At this point you need > > (use-modules (fact)) > >> ;; Create a module named `fac`. >> ;; Export the `main` procedure as part of `fac`. >> >> (define (n-choose-k n k) >> (/ (fact n) >> (* (fact k) >> (fact (- n k))))) >> >> (define (main args) >> (let ((n (string->number (cadr args))) >> (k (string->number (caddr args)))) >> (display (n-choose-k n k)) >> (newline))) >> ----8<----end-of-code---->8---- >> >> And I have the following `fact.scm`: >> >> ----8<----start-of-code---->8---- >> #!/usr/local/bin/guile \ >> -e main -s >> !# >> >> ;; How to run this program? >> ;; Example: >> ;; guile -e main -s factorial-script.scm 50 >> ;; Explanation: >> ;; -e specifies the procedure to run >> ;; -s specifies to run this as a script >> ;; 50 is the number we take as input to the script > > To be usable as module, this needs to be defined as module: > > (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)) >> ----8<----end-of-code---->8---- > =E2=80=A6 >> chmod +x modules.scm >> ./modules.scm 10 3 > > Does it work with the added module definition and import? Thank you for the above explanations. I got confused by the this in the documentation as well. Trying the above suggestions, I still have a problem. I have the following two files: fact: --8<---------------cut here---------------start------------->8--- #!/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)) --8<---------------cut here---------------end--------------->8--- fac: --8<---------------cut here---------------start------------->8--- #!/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))) --8<---------------cut here---------------end--------------->8--- But with Guile 3.0.8, this gives me: --8<---------------cut here---------------start------------->8--- ./fac 5 20 ice-9/read.scm:126:4: In procedure lp: #<unknown port>:1:4: unexpected end of input while searching for: ) --8<---------------cut here---------------end--------------->8--- Which I don't understand. --=20 Thanks, Maxim
bug-guile@HIDDEN
:bug#36682
; Package guile
.
Full text available.Received: (at 36682) by debbugs.gnu.org; 15 Jul 2019 23:45:05 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Mon Jul 15 19:45:05 2019 Received: from localhost ([127.0.0.1]:49399 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1hnAeW-0000HQ-M0 for submit <at> debbugs.gnu.org; Mon, 15 Jul 2019 19:45:04 -0400 Received: from mout.web.de ([212.227.15.3]:51939) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <arne_bab@HIDDEN>) id 1hnAeR-0000Ga-Gv for 36682 <at> debbugs.gnu.org; Mon, 15 Jul 2019 19:45:00 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=dbaedf251592; t=1563234286; bh=9dBohTMoCRmdX90i+AFyztdqjwsJ5O9VANvynXylg6g=; h=X-UI-Sender-Class:References:From:To:Cc:Subject:In-reply-to:Date; b=gBTuhqJWX2s2xycO22jXeN9ssHMXoM1jVOS9txfdzi+igMBpA27woiIEesfMPyICW d3FRhxrS6/+KBMctr0qqSK0yHNZMP2QQq4qCf92CINpVQK9jCw1ci4yXttmPZDGdAX BuzwH2dR60TauUvkWjjadWB3F7/yosbcwZZFfDz8= X-UI-Sender-Class: c548c8c5-30a9-4db5-a2e7-cb6cb037b8f9 Received: from fluss ([84.149.83.171]) by smtp.web.de (mrweb001 [213.165.67.108]) with ESMTPSA (Nemesis) id 0Lj2TO-1iJjyV3rig-00dCOJ; Tue, 16 Jul 2019 01:44:46 +0200 References: <6956abda-8d34-8f3a-0816-9faacee7c7e7@HIDDEN> User-agent: mu4e 1.2.0; emacs 26.2 From: Arne Babenhauserheide <arne_bab@HIDDEN> To: bug-guile@HIDDEN Subject: Re: bug#36682: Error in Guile scripting examples In-reply-to: <6956abda-8d34-8f3a-0816-9faacee7c7e7@HIDDEN> Date: Tue, 16 Jul 2019 01:44:39 +0200 Message-ID: <875zo2g8wo.fsf@HIDDEN> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" X-Provags-ID: V03:K1:L+sHWg1zxQpDE+Rgcn43Me6z8FM5mVcmCWeaHUg6NsyTx+IY2jR JCCmRqig7gERITbm3f2TnLG2LgD3ycDvPlr4u7w6TbqZ3B8BdHnbabf2XjUmYt8x7PEezZN 53ItuU1VQv91BMXXtFi2BtdeR6oO/Zh7JCSTB0YrNPT3A+a50FRruJC8HToXW22EZi6TU6F hVvgAejkHc4w9LOZ/pe+w== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:EvkDqP4ZVbo=:TXk7FdgdlofiG6Njswpq/H Jloy5jwtY/smTNr8+fH108FityQ1tV10M8FKBFWBc/j2K9b0BXKXi94ENXj5AvudaI2qjyyGd pZrYoLSGovYqb7+WEPbYEx5+BF54X3CfFBvqP3TIr/bI4lNDFcFjItZ+8lfW4LsCbpq5WPNnZ v0qin2zfGo1P62gXgbzQKDnk7X7dp7udWKoTuEZx0orFUxU8J5I+UGbViasdaBQJJF3GelSC8 QzIu4rKoPSU4tnqCMaQo2V2JMELfAhcLQCYtVosBAlv9PKYHwTLzLIQLA6uAaYO61UmpqK+bg OblKShH187ibu8MWsrHvSn6ZJsQx7XbZ3K9aUo35y2D7FqgQVUEkSOPSyZsHUQpLze3ZVBAft hcR8AaPFNS3aZHyeXNrKqYJqUVuau7em09J2ioWyjMLD5H36jK1Y5m6VY5BPOYXFB2LfRjViM I6m8lJ0mqDKblm/C/aepMJCRgDX5ZgQIZSZFRl5rt9YOZmIC6rKa3nc31ZzqudSR/qtUVd2xx KTCfzJzoVlrupxLunxh+sFP0Dmz+/5Z3lNpruDesFrzNQEx/yeb5NZA3qrc0xvsDYOueB39e+ 0KdOsHmYZgtSvNfb5rH7UwzoBY7Pw3Z4Guot26qb6QhUtB4I3RwyTyqwr9bFhj4exZ5D7cHaO 9Xko= X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 36682 Cc: 36682 <at> debbugs.gnu.org X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hello Hans-Werner Roitzsch, It looks like you=E2=80=99re mixing up two concepts: the fac creates a modu= le and loads the fact which is not a module, so basically main and choose live in another namespace than fact (define-module starts a new namespace). And it seems that this is indeed a bug in the documentation, because https://www.gnu.org/software/guile/manual/html_node/Scripting-Examples.html= #Scripting-Examples jumps to defining fac as a module but does not at the same time define and import fact as a module, too. Hans-Werner Roitzsch <hwroitzsch@HIDDEN> writes: > I have the file `modules.scm` with the following code: > > ----8<----start-of-code---->8---- > #!/usr/bin/env sh > exec guile -l fact.scm -e '(@ (my-module) main)' -s "$0" "$@" > !# > > ;; Explanation: > ;; -e (my-module) > ;; If run as a script run the `my-module` module's `main`. > ;; (Use `@@` to reference not exported procedures.) > ;; -s > ;; Run the script. > > (define-module (my-module) > #:export (main)) At this point you need (use-modules (fact)) > ;; Create a module named `fac`. > ;; Export the `main` procedure as part of `fac`. > > (define (n-choose-k n k) > (/ (fact n) > (* (fact k) > (fact (- n k))))) > > (define (main args) > (let ((n (string->number (cadr args))) > (k (string->number (caddr args)))) > (display (n-choose-k n k)) > (newline))) > ----8<----end-of-code---->8---- > > And I have the following `fact.scm`: > > ----8<----start-of-code---->8---- > #!/usr/local/bin/guile \ > -e main -s > !# > > ;; How to run this program? > ;; Example: > ;; guile -e main -s factorial-script.scm 50 > ;; Explanation: > ;; -e specifies the procedure to run > ;; -s specifies to run this as a script > ;; 50 is the number we take as input to the script To be usable as module, this needs to be defined as module: (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)) > ----8<----end-of-code---->8---- =E2=80=A6 > chmod +x modules.scm > ./modules.scm 10 3 Does it work with the added module definition and import? If yes, then this looks like a bug in the documentation. > Best regards, > > Hans-Werner Roitzsch Best wishes, and thank you for reporting! Arne =2D- Unpolitisch sein hei=C3=9Ft politisch sein ohne es zu merken --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEE801qEjXQSQPNItXAE++NRSQDw+sFAl0tD+oACgkQE++NRSQD w+uv/A//TFj/xrwPZNtlVlTG4tbyISUg/fGU0Z8EnFS/BzHgsG26Z/KBW58MJ/fW lfAWdYOnzauXa+DJU4LHs/HEfBNgYEsXFXur56OZA39bJ4F2WiRgZibcfHD45Rwt RC8txwbldyUHz1AW009LHyGJqxlt+wAhf24VFMDdbaLFxZrG/O81YLx9nzHXumea hFoQt8JIMPvjjoWgjm18LPCYC2bDChkIYdLDrBDSWhKJx2SuWSdJftpAsmxI0+Dh 2ChT5F6UT48Kzh/ymU1xCf1wTpb1H91x5fZJS1xYSfLIes9pkQM1qCDzY00xYhW4 CsUuSXqK+4WadEK9L1ggtMOIdxpKfElEhaz+gsG8NqOMPg8NOL93IDap7i1y5aTY tuKi7AoJ1Rp8eJCCdXuX9Nc5/674OKlc9YptFaWW9VfvuePVw1wrYoKsa2qcfKZE KcTr77BIt1DfIrBJsPXtfyG5diC/pb09JK7SgD2d77lp28DVdFVRHWyC/+GwVAyY 6/GQvX7PCFVeDierSYbkKaK+s1fohtl3Wek28Z9pgLMFbj3FilHwE/Q/X1UIsvQF pgix2uyUeBxofevoVTwxZTrrZ6UAbT/jN5c2/6mzaRiMAogc673qwBz/yHLNpAQr yULU8Xz/Cy4t2wAQv8fVsnzkjpSijGtIo39eppVnhxxug7HaJ3OIswQBAQgAHRYh BN0ovebZh1yrzkqLHdzPDbMLwQVIBQJdLQ/qAAoJENzPDbMLwQVI8OcD/iKSTl+x etXZzW46EajYzN6uweCViwt3jApIAFPj7rL604XAR9BmnxeEC0o8IfceIHyJ4YsH lAdTJOEvG40whMnUYhIYsCncEWkjvzXoqHPljY8j4ZT2/OBH2r5JLlfB3oMSBvWg qnBRLa093dldcgjMwS8IKjd1C1YGikD20GuT =d4KY -----END PGP SIGNATURE----- --=-=-=--
bug-guile@HIDDEN
:bug#36682
; Package guile
.
Full text available.Received: (at submit) by debbugs.gnu.org; 15 Jul 2019 23:45:08 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Mon Jul 15 19:45:08 2019 Received: from localhost ([127.0.0.1]:49402 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1hnAea-0000Hh-2U for submit <at> debbugs.gnu.org; Mon, 15 Jul 2019 19:45:08 -0400 Received: from lists.gnu.org ([209.51.188.17]:42824) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <arne_bab@HIDDEN>) id 1hnAeY-0000Ha-Kv for submit <at> debbugs.gnu.org; Mon, 15 Jul 2019 19:45:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41884) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from <arne_bab@HIDDEN>) id 1hnAeX-0004Oc-Fy for bug-guile@HIDDEN; Mon, 15 Jul 2019 19:45:06 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,URIBL_BLOCKED autolearn=disabled version=3.3.2 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from <arne_bab@HIDDEN>) id 1hnAeW-0000FA-8w for bug-guile@HIDDEN; Mon, 15 Jul 2019 19:45:05 -0400 Received: from mout.web.de ([212.227.15.3]:56563) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from <arne_bab@HIDDEN>) id 1hnAeV-0000CS-Vz for bug-guile@HIDDEN; Mon, 15 Jul 2019 19:45:04 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=dbaedf251592; t=1563234286; bh=9dBohTMoCRmdX90i+AFyztdqjwsJ5O9VANvynXylg6g=; h=X-UI-Sender-Class:References:From:To:Cc:Subject:In-reply-to:Date; b=gBTuhqJWX2s2xycO22jXeN9ssHMXoM1jVOS9txfdzi+igMBpA27woiIEesfMPyICW d3FRhxrS6/+KBMctr0qqSK0yHNZMP2QQq4qCf92CINpVQK9jCw1ci4yXttmPZDGdAX BuzwH2dR60TauUvkWjjadWB3F7/yosbcwZZFfDz8= X-UI-Sender-Class: c548c8c5-30a9-4db5-a2e7-cb6cb037b8f9 Received: from fluss ([84.149.83.171]) by smtp.web.de (mrweb001 [213.165.67.108]) with ESMTPSA (Nemesis) id 0Lj2TO-1iJjyV3rig-00dCOJ; Tue, 16 Jul 2019 01:44:46 +0200 References: <6956abda-8d34-8f3a-0816-9faacee7c7e7@HIDDEN> User-agent: mu4e 1.2.0; emacs 26.2 From: Arne Babenhauserheide <arne_bab@HIDDEN> To: bug-guile@HIDDEN Subject: Re: bug#36682: Error in Guile scripting examples In-reply-to: <6956abda-8d34-8f3a-0816-9faacee7c7e7@HIDDEN> Date: Tue, 16 Jul 2019 01:44:39 +0200 Message-ID: <875zo2g8wo.fsf@HIDDEN> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" X-Provags-ID: V03:K1:L+sHWg1zxQpDE+Rgcn43Me6z8FM5mVcmCWeaHUg6NsyTx+IY2jR JCCmRqig7gERITbm3f2TnLG2LgD3ycDvPlr4u7w6TbqZ3B8BdHnbabf2XjUmYt8x7PEezZN 53ItuU1VQv91BMXXtFi2BtdeR6oO/Zh7JCSTB0YrNPT3A+a50FRruJC8HToXW22EZi6TU6F hVvgAejkHc4w9LOZ/pe+w== X-UI-Out-Filterresults: notjunk:1;V03:K0:EvkDqP4ZVbo=:TXk7FdgdlofiG6Njswpq/H Jloy5jwtY/smTNr8+fH108FityQ1tV10M8FKBFWBc/j2K9b0BXKXi94ENXj5AvudaI2qjyyGd pZrYoLSGovYqb7+WEPbYEx5+BF54X3CfFBvqP3TIr/bI4lNDFcFjItZ+8lfW4LsCbpq5WPNnZ v0qin2zfGo1P62gXgbzQKDnk7X7dp7udWKoTuEZx0orFUxU8J5I+UGbViasdaBQJJF3GelSC8 QzIu4rKoPSU4tnqCMaQo2V2JMELfAhcLQCYtVosBAlv9PKYHwTLzLIQLA6uAaYO61UmpqK+bg OblKShH187ibu8MWsrHvSn6ZJsQx7XbZ3K9aUo35y2D7FqgQVUEkSOPSyZsHUQpLze3ZVBAft hcR8AaPFNS3aZHyeXNrKqYJqUVuau7em09J2ioWyjMLD5H36jK1Y5m6VY5BPOYXFB2LfRjViM I6m8lJ0mqDKblm/C/aepMJCRgDX5ZgQIZSZFRl5rt9YOZmIC6rKa3nc31ZzqudSR/qtUVd2xx KTCfzJzoVlrupxLunxh+sFP0Dmz+/5Z3lNpruDesFrzNQEx/yeb5NZA3qrc0xvsDYOueB39e+ 0KdOsHmYZgtSvNfb5rH7UwzoBY7Pw3Z4Guot26qb6QhUtB4I3RwyTyqwr9bFhj4exZ5D7cHaO 9Xko= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 212.227.15.3 X-Spam-Score: -1.4 (-) X-Debbugs-Envelope-To: submit Cc: 36682 <at> debbugs.gnu.org X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -2.4 (--) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hello Hans-Werner Roitzsch, It looks like you=E2=80=99re mixing up two concepts: the fac creates a modu= le and loads the fact which is not a module, so basically main and choose live in another namespace than fact (define-module starts a new namespace). And it seems that this is indeed a bug in the documentation, because https://www.gnu.org/software/guile/manual/html_node/Scripting-Examples.html= #Scripting-Examples jumps to defining fac as a module but does not at the same time define and import fact as a module, too. Hans-Werner Roitzsch <hwroitzsch@HIDDEN> writes: > I have the file `modules.scm` with the following code: > > ----8<----start-of-code---->8---- > #!/usr/bin/env sh > exec guile -l fact.scm -e '(@ (my-module) main)' -s "$0" "$@" > !# > > ;; Explanation: > ;; -e (my-module) > ;; If run as a script run the `my-module` module's `main`. > ;; (Use `@@` to reference not exported procedures.) > ;; -s > ;; Run the script. > > (define-module (my-module) > #:export (main)) At this point you need (use-modules (fact)) > ;; Create a module named `fac`. > ;; Export the `main` procedure as part of `fac`. > > (define (n-choose-k n k) > (/ (fact n) > (* (fact k) > (fact (- n k))))) > > (define (main args) > (let ((n (string->number (cadr args))) > (k (string->number (caddr args)))) > (display (n-choose-k n k)) > (newline))) > ----8<----end-of-code---->8---- > > And I have the following `fact.scm`: > > ----8<----start-of-code---->8---- > #!/usr/local/bin/guile \ > -e main -s > !# > > ;; How to run this program? > ;; Example: > ;; guile -e main -s factorial-script.scm 50 > ;; Explanation: > ;; -e specifies the procedure to run > ;; -s specifies to run this as a script > ;; 50 is the number we take as input to the script To be usable as module, this needs to be defined as module: (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)) > ----8<----end-of-code---->8---- =E2=80=A6 > chmod +x modules.scm > ./modules.scm 10 3 Does it work with the added module definition and import? If yes, then this looks like a bug in the documentation. > Best regards, > > Hans-Werner Roitzsch Best wishes, and thank you for reporting! Arne =2D- Unpolitisch sein hei=C3=9Ft politisch sein ohne es zu merken --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEE801qEjXQSQPNItXAE++NRSQDw+sFAl0tD+oACgkQE++NRSQD w+uv/A//TFj/xrwPZNtlVlTG4tbyISUg/fGU0Z8EnFS/BzHgsG26Z/KBW58MJ/fW lfAWdYOnzauXa+DJU4LHs/HEfBNgYEsXFXur56OZA39bJ4F2WiRgZibcfHD45Rwt RC8txwbldyUHz1AW009LHyGJqxlt+wAhf24VFMDdbaLFxZrG/O81YLx9nzHXumea hFoQt8JIMPvjjoWgjm18LPCYC2bDChkIYdLDrBDSWhKJx2SuWSdJftpAsmxI0+Dh 2ChT5F6UT48Kzh/ymU1xCf1wTpb1H91x5fZJS1xYSfLIes9pkQM1qCDzY00xYhW4 CsUuSXqK+4WadEK9L1ggtMOIdxpKfElEhaz+gsG8NqOMPg8NOL93IDap7i1y5aTY tuKi7AoJ1Rp8eJCCdXuX9Nc5/674OKlc9YptFaWW9VfvuePVw1wrYoKsa2qcfKZE KcTr77BIt1DfIrBJsPXtfyG5diC/pb09JK7SgD2d77lp28DVdFVRHWyC/+GwVAyY 6/GQvX7PCFVeDierSYbkKaK+s1fohtl3Wek28Z9pgLMFbj3FilHwE/Q/X1UIsvQF pgix2uyUeBxofevoVTwxZTrrZ6UAbT/jN5c2/6mzaRiMAogc673qwBz/yHLNpAQr yULU8Xz/Cy4t2wAQv8fVsnzkjpSijGtIo39eppVnhxxug7HaJ3OIswQBAQgAHRYh BN0ovebZh1yrzkqLHdzPDbMLwQVIBQJdLQ/qAAoJENzPDbMLwQVI8OcD/iKSTl+x etXZzW46EajYzN6uweCViwt3jApIAFPj7rL604XAR9BmnxeEC0o8IfceIHyJ4YsH lAdTJOEvG40whMnUYhIYsCncEWkjvzXoqHPljY8j4ZT2/OBH2r5JLlfB3oMSBvWg qnBRLa093dldcgjMwS8IKjd1C1YGikD20GuT =d4KY -----END PGP SIGNATURE----- --=-=-=--
bug-guile@HIDDEN
:bug#36682
; Package guile
.
Full text available.Received: (at submit) by debbugs.gnu.org; 15 Jul 2019 23:19:52 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Mon Jul 15 19:19:52 2019 Received: from localhost ([127.0.0.1]:49384 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1hnAG6-00084F-F1 for submit <at> debbugs.gnu.org; Mon, 15 Jul 2019 19:19:52 -0400 Received: from lists.gnu.org ([209.51.188.17]:45614) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <hwroitzsch@HIDDEN>) id 1hn9fX-00079q-Ez for submit <at> debbugs.gnu.org; Mon, 15 Jul 2019 18:42:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59258) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from <hwroitzsch@HIDDEN>) id 1hn9fV-0002or-RD for bug-guile@HIDDEN; Mon, 15 Jul 2019 18:42:03 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,HTML_MESSAGE, RCVD_IN_DNSWL_MED,URIBL_BLOCKED autolearn=disabled version=3.3.2 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from <hwroitzsch@HIDDEN>) id 1hn9fT-0003Cs-NH for bug-guile@HIDDEN; Mon, 15 Jul 2019 18:42:01 -0400 Received: from mout02.posteo.de ([185.67.36.66]:40139) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from <hwroitzsch@HIDDEN>) id 1hn9fT-0003An-4B for bug-guile@HIDDEN; Mon, 15 Jul 2019 18:41:59 -0400 Received: from submission (posteo.de [89.146.220.130]) by mout02.posteo.de (Postfix) with ESMTPS id 884012400E5 for <bug-guile@HIDDEN>; Tue, 16 Jul 2019 00:41:56 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1563230516; bh=txTSSqhWWLBVWC8AvltNEhfuG3CazhVb+qXBsykO8U8=; h=To:From:Subject:Date:From; b=obRTBo1HJx7XL84VqoijY9641U6itXhVKOGJzSNEVrG30P4jUUGEQU75B5DyR3aKI iQdscqLjSNwNMo1fp6IFRRseGtUSHUlBVrNks0kfZQb71Q1HUfaBG98FOB83JYNU0z 1l3xltjBkFRVvMHJZZmpdB99XmM5Wdis8YNTbpfyrd5KA0fpQ8CwV9q2zYqb9TJKgF Khm0mA8uW0PPutuOEbRYmOhJ3INosrul1i1y6prA2TWG85uIpv8tQUuAHYPYxFg9/U W489en1K2Z8PmETouAadTBT/iz2izSUnW9k/0/peLTJ5anJbdKwIMMuPpxwZJaCKRy XeQb4YhiLDRkw== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 45ndnH4YK3z9rxG for <bug-guile@HIDDEN>; Tue, 16 Jul 2019 00:41:55 +0200 (CEST) To: bug-guile@HIDDEN From: Hans-Werner Roitzsch <hwroitzsch@HIDDEN> Subject: Error in Guile scripting examples Message-ID: <6956abda-8d34-8f3a-0816-9faacee7c7e7@HIDDEN> Date: Tue, 16 Jul 2019 00:39:43 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="------------EFCA7833A77C60E9DDD2AD1B" Content-Language: en-US X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 185.67.36.66 X-Spam-Score: -1.3 (-) X-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Mon, 15 Jul 2019 19:19:48 -0400 X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -2.3 (--) This is a multi-part message in MIME format. --------------EFCA7833A77C60E9DDD2AD1B Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hello GNU Team! I wish to report a bug in either Guile's documentation or Guile's code with regard to running scripts. There are some examples of that given in Guile's documentation at: https://www.gnu.org/software/guile/manual/html_node/Scripting-Examples.ht= ml#Scripting-Examples In the following I will describe the problem. I have the file `modules.scm` with the following code: ----8<----start-of-code---->8---- #!/usr/bin/env sh exec guile -l fact.scm -e '(@ (my-module) main)' -s "$0" "$@" !# ;; Explanation: ;; -e (my-module) ;; If run as a script run the `my-module` module's `main`. ;; (Use `@@` to reference not exported procedures.) ;; -s ;; Run the script. (define-module (my-module) =C2=A0 #:export (main)) ;; Create a module named `fac`. ;; Export the `main` procedure as part of `fac`. (define (n-choose-k n k) =C2=A0 (/ (fact n) =C2=A0=C2=A0=C2=A0=C2=A0 (* (fact k) =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (fact (- n k))))) (define (main args) =C2=A0 (let ((n (string->number (cadr args))) =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (k (string->number (caddr args= )))) =C2=A0=C2=A0=C2=A0 (display (n-choose-k n k)) =C2=A0=C2=A0=C2=A0 (newline))) ----8<----end-of-code---->8---- And I have the following `fact.scm`: ----8<----start-of-code---->8---- #!/usr/local/bin/guile \ -e main -s !# ;; How to run this program? ;; Example: ;; guile -e main -s factorial-script.scm 50 ;; Explanation: ;; -e specifies the procedure to run ;; -s specifies to run this as a script ;; 50 is the number we take as input to the script (define (fact n) =C2=A0 (if (zero? n) 1 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (* n (fact (- n 1))))) (define (main args) =C2=A0 (display (fact (string->number (cadr args)))) =C2=A0 (newline)) ----8<----end-of-code---->8---- The script is made executable by doing: chmod +x modules.scm Then I call the script as follows: ./modules.scm 10 3 This results in the error: ----8<----start-of-code---->8---- Backtrace: =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 4 (apply-smo= b/1 #<catch-closure 119cb80>) In ice-9/boot-9.scm: =C2=A0=C2=A0=C2=A0 705:2=C2=A0 3 (call-with-prompt ("prompt") #<procedure= 11aa8e0 at ice-9/eval.scm:330:13 ()> #<procedure default-prom=E2=80=A6>) In ice-9/eval.scm: =C2=A0=C2=A0=C2=A0 619:8=C2=A0 2 (_ #(#(#<directory (guile-user) 1233140>= ))) In /home/xiaolong/development/Guile/scripting/./modules.scm: =C2=A0=C2=A0=C2=A0 26:13=C2=A0 1 (main _) =C2=A0=C2=A0=C2=A0=C2=A0 18:0=C2=A0 0 (n-choose-k _ _) /home/xiaolong/development/Guile/scripting/./modules.scm:18:0: In procedu= re n-choose-k: In procedure module-lookup: Unbound variable: fact ----8<----end-of-code---->8---- According to my understanding of the tutorial in the Guile documentation that I linked to above this code should work. I also described the problem some time ago at: https://stackoverflow.com/questions/50272618/guile-scheme-scripting-tutor= ial-loading-scripts My Guile version is: guile (GNU Guile) 2.2.4 Best regards, Hans-Werner Roitzsch --------------EFCA7833A77C60E9DDD2AD1B Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable <html> <head> <meta http-equiv=3D"content-type" content=3D"text/html; charset=3DUTF= -8"> </head> <body bgcolor=3D"#FFFFFF" text=3D"#000000"> <p>Hello GNU Team!</p> <p>I wish to report a bug in either Guile's documentation or Guile's code with regard to running scripts.</p> <p>There are some examples of that given in Guile's documentation at:</p> <p><a class=3D"moz-txt-link-freetext" href=3D"https://www.gnu.org/sof= tware/guile/manual/html_node/Scripting-Examples.html#Scripting-Examples">= https://www.gnu.org/software/guile/manual/html_node/Scripting-Examples.ht= ml#Scripting-Examples</a></p> <p>In the following I will describe the problem.</p> <p><br> </p> <p>I have the file `modules.scm` with the following code:</p> <pre>----8<----start-of-code---->8---- #!/usr/bin/env sh exec guile -l fact.scm -e '(@ (my-module) main)' -s "$0" "$@" !# ;; Explanation: ;; -e (my-module) ;; If run as a script run the `my-module` module's `main`. ;; (Use `@@` to reference not exported procedures.) ;; -s ;; Run the script. (define-module (my-module) =C2=A0 #:export (main)) ;; Create a module named `fac`. ;; Export the `main` procedure as part of `fac`. (define (n-choose-k n k) =C2=A0 (/ (fact n) =C2=A0=C2=A0=C2=A0=C2=A0 (* (fact k) =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (fact (- n k))))) (define (main args) =C2=A0 (let ((n (string->number (cadr args))) =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (k (string->number (caddr a= rgs)))) =C2=A0=C2=A0=C2=A0 (display (n-choose-k n k)) =C2=A0=C2=A0=C2=A0 (newline))) ----8<----end-of-code---->8----</pre> <p>And I have the following `fact.scm`:</p> <pre>----8<----start-of-code---->8---- #!/usr/local/bin/guile \ -e main -s !# ;; How to run this program? ;; Example: ;; guile -e main -s factorial-script.scm 50 ;; Explanation: ;; -e specifies the procedure to run ;; -s specifies to run this as a script ;; 50 is the number we take as input to the script (define (fact n) =C2=A0 (if (zero? n) 1 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (* n (fact (- n 1))))) (define (main args) =C2=A0 (display (fact (string->number (cadr args)))) =C2=A0 (newline)) ----8<----end-of-code---->8----</pre> <p>The script is made executable by doing: <br> </p> <pre>chmod +x modules.scm </pre> <p>Then I call the script as follows:</p> <pre>./modules.scm 10 3</pre> <p>This results in the error:</p> <pre>----8<----start-of-code---->8---- Backtrace: =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 4 (apply-smo= b/1 #<catch-closure 119cb80>) In ice-9/boot-9.scm: =C2=A0=C2=A0=C2=A0 705:2=C2=A0 3 (call-with-prompt ("prompt") #<proced= ure 11aa8e0 at ice-9/eval.scm:330:13 ()> #<procedure default-prom=E2= =80=A6>) In ice-9/eval.scm: =C2=A0=C2=A0=C2=A0 619:8=C2=A0 2 (_ #(#(#<directory (guile-user) 12331= 40>))) In /home/xiaolong/development/Guile/scripting/./modules.scm: =C2=A0=C2=A0=C2=A0 26:13=C2=A0 1 (main _) =C2=A0=C2=A0=C2=A0=C2=A0 18:0=C2=A0 0 (n-choose-k _ _) /home/xiaolong/development/Guile/scripting/./modules.scm:18:0: In procedu= re n-choose-k: In procedure module-lookup: Unbound variable: fact ----8<----end-of-code---->8---- </pre> <p>According to my understanding of the tutorial in the Guile documentation that I linked to above this code should work.</p> <p>I also described the problem some time ago at:</p> <p><a class=3D"moz-txt-link-freetext" href=3D"https://stackoverflow.c= om/questions/50272618/guile-scheme-scripting-tutorial-loading-scripts">ht= tps://stackoverflow.com/questions/50272618/guile-scheme-scripting-tutoria= l-loading-scripts</a></p> <p>My Guile version is:</p> <pre>guile (GNU Guile) 2.2.4 </pre> <p>Best regards,</p> <p>Hans-Werner Roitzsch<br> </p> </body> </html> --------------EFCA7833A77C60E9DDD2AD1B--
Hans-Werner Roitzsch <hwroitzsch@HIDDEN>
:bug-guile@HIDDEN
.
Full text available.bug-guile@HIDDEN
:bug#36682
; Package guile
.
Full text available.
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997 nCipher Corporation Ltd,
1994-97 Ian Jackson.