From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Arne Babenhauserheide Newsgroups: gmane.lisp.guile.devel Subject: Re: [PATCH] doc: describe the -e (module) shorthand as on equal footing with (@ ...) Date: Tue, 07 Feb 2017 15:16:48 +0100 Message-ID: <87y3xidr1r.fsf@web.de> References: <8760sv3atk.fsf@web.de> <87r3bj835b.fsf@pobox.com> <8760sisc4j.fsf@web.de> <87shvl698r.fsf@pobox.com> <87oa36g2kw.fsf@web.de> <87lgvvcmg6.fsf@web.de> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" X-Trace: blaine.gmane.org 1486479555 12140 195.159.176.226 (7 Feb 2017 14:59:15 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 7 Feb 2017 14:59:15 +0000 (UTC) User-Agent: mu4e 0.9.16; emacs 25.1.1 Cc: guile-devel@gnu.org To: Andy Wingo Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Tue Feb 07 15:59:10 2017 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cb7Ec-0002xV-9Q for guile-devel@m.gmane.org; Tue, 07 Feb 2017 15:59:10 +0100 Original-Received: from localhost ([::1]:54564 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cb7Ei-00046R-0c for guile-devel@m.gmane.org; Tue, 07 Feb 2017 09:59:16 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:40528) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cb6Zu-0004Fw-CK for guile-devel@gnu.org; Tue, 07 Feb 2017 09:17:07 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cb6Zr-0005Uh-5K for guile-devel@gnu.org; Tue, 07 Feb 2017 09:17:06 -0500 Original-Received: from mout.web.de ([212.227.17.12]:60155) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cb6Zq-0005Sr-RJ for guile-devel@gnu.org; Tue, 07 Feb 2017 09:17:03 -0500 Original-Received: from fluss ([85.212.124.148]) by smtp.web.de (mrweb103 [213.165.67.124]) with ESMTPSA (Nemesis) id 0MOArg-1cXmeQ34fk-005bUz; Tue, 07 Feb 2017 15:16:55 +0100 In-reply-to: <87lgvvcmg6.fsf@web.de> X-Provags-ID: V03:K0:lqKSU3QdvYsylylYzNXyxloqSLfkc+oBd3qkQ5R4dJDpCATAhXZ 77y+F9PqGOQkwjwEK7Abar+rLhG3FhH/MQg+gQlQS9Ll8pIRL2w0slZqhKCAZJ9nQL1mlZC hqXkO1T2n72PSyPRhN6vDDMpXZvVQU0aCT1PfgehEuV5J48DZ4/vty5Ujw3oD7gu/glgDdU xYG/vmtsXvnz8BsxZ0VCw== X-UI-Out-Filterresults: notjunk:1;V01:K0:xQGLFTQIhdk=:WFrHfe2QNl4iP4tIzO2CbH Djy6oo4UFF9Nxsnj/6rJaHZrhvga4+ByMV27tBrAyJISUonwl28Vh15e2CfNobYZkgSo31aQ4 T8/qRGzFYeGSe72hmS07HE0mUunv4kbnJLqwEiXcIU7s0cJDcw1CLEXzoTFaeIxWrZ9laBhw+ Zr77cC5/HgzfaLcr4URGnKKVLqSGzW48pDaE5UDOewKVAvWrv2UBx+LOPD2UUeqEXfZFCuPi1 nmdVruAjr0B7pk5qks5XKZzU2cJljyoT6SmGS+Ql/Xumsm+69TfQBo8fYN4HQ04Ds6HKcnrxr P/ymaxAZSoAxDR0mvfXLGIj2XwyRaYMFLdxvFLbbSSYJpdNRKwaJP8UGQo6zLlPI8bdeaRJLX ZCGVbxPg7NBmUxgS2Zz6P90ekiRe6Y2ikjxcF/RM7jJhBWwDkLAUMzH8A4Uv2aQOq3yku4UaG T31ZkaheK039qr8b3RmX5xgxZyCqjDIjKvTUDAW57I3Ztg/+PexfOFwvyBSrKfUcY1Hv5UtoG RaEMKWC4aq60zJLqNfjKfGcPnvoCXdlgOsXVE5gyZ4d4+epSQnOEH1IB1+tOuZG8WMbuCom6j 7SAkO2LWgtUNtn/8aK0ku2PCSde9q8gnQSGA7mtt7s69GKmfiP9z9miKuRl0jPRexbnBpWWRJ XO6UqnDqUi4xqzE55fi338alVSE3iJf4yclDRe7ERAOw59+omAhzZm2afAOJGzwMbZGGhpN28 2FwNuReLYzAfVnPpaI7cY4w4x8I8vfc2HQfqTr7aM3KQ5KcGQsB6qLl6s+0= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 212.227.17.12 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Original-Sender: "guile-devel" Xref: news.gmane.org gmane.lisp.guile.devel:18894 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hi, Any update on this? Best wishes, Arne Arne Babenhauserheide writes: > Hi, > > Is something missing in the patch which is needed to merge it? > > Arne Babenhauserheide writes: > >> Is this OK? >> >> From 4751b9c4c85152281f0d57eda6a1c4ce50166ad4 Mon Sep 17 00:00:00 2001 >> From: Arne Babenhauserheide >> Date: Thu, 29 Sep 2016 17:11:26 +0200 >> Subject: [PATCH] describe the -e (module) shorthand as on equal footing = with >> (@ ...) >> >> * doc/ref/guile-invoke.texi, doc/ref/scheme-scripts.texi: >> describe the -e (module) shorthand as on equal footing with (@ ...) >> --- >> doc/ref/guile-invoke.texi | 15 +++++------ >> doc/ref/scheme-scripts.texi | 62 ++++++++++++++++++++++++++++++++++++++= +++++++ >> 2 files changed, 68 insertions(+), 9 deletions(-) >> >> diff --git a/doc/ref/guile-invoke.texi b/doc/ref/guile-invoke.texi >> index bc33ce0..e25960a 100644 >> --- a/doc/ref/guile-invoke.texi >> +++ b/doc/ref/guile-invoke.texi >> @@ -102,15 +102,12 @@ that is defined in the script. It can also be of = the form @code{(@@ >> @var{module-name} @var{symbol})}, and in that case, the symbol is >> looked up in the module named @var{module-name}. >>=20=20 >> -For compatibility with some versions of Guile 1.4, you can also use the >> -form @code{(symbol ...)} (that is, a list of only symbols that doesn't >> -start with @code{@@}), which is equivalent to @code{(@@ (symbol ...) >> -main)}, or @code{(symbol ...) symbol} (that is, a list of only symbols >> -followed by a symbol), which is equivalent to @code{(@@ (symbol ...) >> -symbol)}. We recommend to use the equivalent forms directly since they >> -correspond to the @code{(@@ ...)} read syntax that can be used in >> -normal code. See @ref{Using Guile Modules} and @ref{Scripting >> -Examples}. >> +As a shorthand you can use the form @code{(symbol ...)}, that is, a >> +list of only symbols that doesn't start with @code{@@}. It is >> +equivalent to @code{(@@ @var{module-name} main)} with @code{(symbol ..= .)} >> +the @var{module-name}. To use a different function than @var{main}, >> +you can use the form @code{(symbol ...) function}. See @ref{Using >> +Guile Modules} and @ref{Scripting Examples}. >>=20=20 >> @item -ds >> Treat a final @option{-s} option as if it occurred at this point in the >> diff --git a/doc/ref/scheme-scripts.texi b/doc/ref/scheme-scripts.texi >> index 7552dba..4999a47 100644 >> --- a/doc/ref/scheme-scripts.texi >> +++ b/doc/ref/scheme-scripts.texi >> @@ -293,6 +293,11 @@ and exit. >> Load the file @file{/u/jimb/ex4}, and then call the function >> @code{main}, passing it the list @code{("/u/jimb/ex4" "foo")}. >>=20=20 >> +@item guile -e '(ex4)' -s /u/jimb/ex4.scm foo >> +Load the file @file{/u/jimb/ex4.scm}, and then call the function >> +@code{main} from the module '(ex4)', passing it the list >> +@code{("/u/jimb/ex4" "foo")}. >> + >> @item guile -l first -ds -l last -s script >> Load the files @file{first}, @file{script}, and @file{last}, in that >> order. The @code{-ds} switch says when to process the @code{-s} >> @@ -402,6 +407,63 @@ $ ./choose 50 100 >> 100891344545564193334812497256 >> @end example >>=20=20 >> +To execute the function main from a module, we can use the special form >> +@code{(@@ (module) function)}: >> +@example >> +#!/usr/local/bin/guile \ >> +-l fact -e (@@ (fac) main) -s >> +!# >> +(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))) >> +@end example >> + >> +We can use @code{@@@@} to run non-exported functions. For exported >> +functions, we can simplify this call with the shorthand @code{(module)}: >> +@example >> +#!/usr/local/bin/guile \ >> +-l fact -e (fac) -s >> +!# >> +(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))) >> +@end example >> + >> +For maximum portability among *nixes, we can use the shell to >> +@code{exec} guile with specified command line arguments. Here we need to >> +take care to quote the command arguments correctly: >> +@example >> +#!/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))) >> +@end example >>=20=20 >> @c Local Variables: >> @c TeX-master: "guile.texi" >> --=20 >> 2.7.3 > > Best wishes, > Arne =2D-=20 Unpolitisch sein hei=C3=9Ft politisch sein ohne es zu merken --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIcBAEBCAAGBQJYmdbRAAoJEBPvjUUkA8Prz2QP/jOZRMn9IXVWMkNuFQMonmkV N8A4HdXqjyidyPYhoFFl0v9JbEqIU/GcQSmUdBITe2EGGaEjqD0fhh2BQcrfu+cx 6jtTmPDGWa3V/t7K+NwbRtwErwOipfGwx7hBQQv4OCSsMNr+e1L+lKkx6UyEQo0Q I1BUAUB/FYLk7xwDCcSzjf1Dr+qxGUE3uo+RnGeCoAfMIXjSnAFQEE965QAae5aQ cKy0UnQAmmfoHWro5bKGrM+uloGa+uv5UxL+Bg37t8rjShjbNYwLuJWEu8NXmc67 IK+OJZaaJGKmKjq2suZie0GxexLS+tiEd1P/ImuL5W3sGf1VVhbyf3rp7CFFTwDW dQ3Q/ZFrb5KOEGPVhMV9XuUxEMThDuMlZFAvCGGm6S14nUqwmz7RKXJ+1heZ+M37 AvKmJEU7CK1CcRqflmAPFZnlAMU6C+zKlEDqE7yG20u10Z7LRffocPzI53BIYhcB 3lPeA7MYc2BiSkauS3zh75jMw/kmxEJQyh4nDtStYjr2QNDhfXy5pZZFVxUNn4V2 BawfqZ7K2fUKda60JjT6N3addrQZSVFTH3Yd287fBf1Dq++RvLnzaGZLQleWKYSg PnNYwJJpC6v7WvnsTmuwrfwmmDtyc5SKcNZ+8ZE8yYeM8SJI6vk5wwKk3VGRXetv gu3LFW+ym+nkc0Y6QKrs =z/0s -----END PGP SIGNATURE----- --=-=-=--