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: Mon, 05 Dec 2016 00:18:49 +0100 Message-ID: <87lgvvcmg6.fsf@web.de> References: <8760sv3atk.fsf@web.de> <87r3bj835b.fsf@pobox.com> <8760sisc4j.fsf@web.de> <87shvl698r.fsf@pobox.com> <87oa36g2kw.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 1480893566 24257 195.159.176.226 (4 Dec 2016 23:19:26 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 4 Dec 2016 23:19:26 +0000 (UTC) User-Agent: mu4e 0.9.16; emacs 24.5.1 Cc: guile-devel@gnu.org To: Andy Wingo Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Mon Dec 05 00:19:20 2016 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 1cDg3v-0004rd-Nw for guile-devel@m.gmane.org; Mon, 05 Dec 2016 00:19:15 +0100 Original-Received: from localhost ([::1]:36030 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cDg3z-0007DU-HZ for guile-devel@m.gmane.org; Sun, 04 Dec 2016 18:19:19 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:58489) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cDg3j-0007DN-Th for guile-devel@gnu.org; Sun, 04 Dec 2016 18:19:05 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cDg3e-00045K-UH for guile-devel@gnu.org; Sun, 04 Dec 2016 18:19:03 -0500 Original-Received: from mout.web.de ([212.227.17.11]:53121) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cDg3e-000456-Kh for guile-devel@gnu.org; Sun, 04 Dec 2016 18:18:58 -0500 Original-Received: from fluss ([85.212.123.150]) by smtp.web.de (mrweb101 [213.165.67.124]) with ESMTPSA (Nemesis) id 0Ma2YF-1by4yi2Is3-00LoyG; Mon, 05 Dec 2016 00:18:51 +0100 In-reply-to: <87oa36g2kw.fsf@web.de> X-Provags-ID: V03:K0:uJBbLYMUvEwdknhaRiihSPKGX4aHn5NSE1Kah2IrWWlHp8Yo6XH bg24kukDiY+IM0IKhleKgg2PugUoDDt7odrDzMmm7FIuZaQLj8ZrNuP3tTiTKghxTt0UEH/ Fe+cG6gQfsAlUzvA4Rx0XB02a1/LLRCZ0fzY8HFx8aEofaUjCG0uDSRXWuxw+gkZyyNbnZa kEyiXnNtRfeWjgVQwHHSg== X-UI-Out-Filterresults: notjunk:1;V01:K0:VvXOLHMLMgg=:Yt4U8/6735TzVUgKwIIwyC FFpZOpb39md/WUwFbmLnw77PzyRVU5hXTByYrKxQGldqM4Rp84pT9lTNES5lQSAetyJxj3YPF eaUPatkJTfqAinny2o+k3Tqk57xJGwnWR+1Bixa/4JkXtgcfal4KahPQ0ekE9qnrXfVJIdjQ9 tAX+O33qZizTjm8ZJYAcwKRP59pysjLIE9UHoHx0hjIxph+xzsZtCfG07cZnq2mPMClvzxG/z 21dVdp0ODgts7yzxV0rYl/iVjIde72xEe6DqySnZP9eooJFQR65a4VUIhSBZe9Bc/DQrVg5uw XSdt5etwD1+EX6aE6Jczbtwn8uYNaSq/OO4a7K+NslSfgI0Rba3LIa57LWQenBc4U94mt4sBA rgH6gK8eg3E+bOxfsEddPJwjopVonRoFVAlL9ZnED2wmazAiPCbngL6xH5apvNWmFidOz4bNP iMBy4QSrWtFoWRkrhvXTs8Kj3bZmoen2pe9YmIsNSZxaAQRs4dOXA7jXJgR4GBqcWa/59FP5J DjGTPxUgyJeC9tGY3ekbRUIY0Fw/1SmpOwue+Q2clUmyyWIWzjMQGgoeu80ULKOSqHxbb1uv9 aG7ZlAUEv5+Dh6PL5gOW4PPXk6Lzbt5tKc7ZP8TXBLtM7ZlIad/vk6hkStACFX+y/wvydwH2H XG1ap8TJT8qgpGyCKwOCYL56i9LiyLh+op+FHKLjPKQNaszsCFzMJRPna0OdQiachmuBUcqsf lVwQ8q5xKif+qsso0mvB/ItKlg3C8gz9aZ2bUfx4lVEfqAeXd5+HXcCJD4g= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 212.227.17.11 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:18774 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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 w= ith > (@ ...) > > * 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 t= he 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----- iQIcBAEBCAAGBQJYRKRaAAoJEBPvjUUkA8Pr7w8QAKV0nX4n/YEA3PVGMHfXHMOM d2oAad/VKiwctE3J6ZADYfXS6+KSbTXwD03KvP3Us7xCFucHbDC6wVz9y/beRL/B YUIhHkCTGezopXVSiIJEJfcBNR/5uusFWnqXMUnVylngNGhT91prigZ4DxBEvJGm zDML9pz6mgPHxUIGA+HUCL33x9nVJZaeHK2Xqnqh5Ja6O5W/U4wJyr21m4b4ozXU BcyhwKnXAyRTOZITE8kpP9DRGfDSKjz1fDZCqJgUq4oxKouLDssi1rFYrPamGuQ6 wcBD/iZD4/4SbwNVlFOM4loVoIdmS82Nqn+g0ayS+guXui1lWVu7vs3s62sDu4+B Cot/gTHxwHh8vP+FYfAMBQVYchw6LzxLgdWrzq1qXxPLAiJaN2UIZkfF7Pe2TiTp +LwwSWUBt2H1IKStRtNWt7KdQ5moXF2WyhgFpr62jjJYDljoyps5FNdMLvtBEJu/ ilM9u0ONBIEJHsljnR1b1GiKR1VDBvqQBQYPiPaynUIzxHVegt09swJcGbYrIjOP r0v4X8qPmKBIeLeVCy8tGC58TFOg9xTYL6NeP1mYlts1UlSA9nsYll4ET7tWDswt gII+XB/i1xCMJzKUU3A0WYjtEPKzjIcynbNphtxgSqqVBeb+7xPiRtsVhOHlCCdv /fiePI6n7S7EygqShvRn =QO7N -----END PGP SIGNATURE----- --=-=-=--