From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!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: Sun, 26 Jun 2016 23:21:59 +0200 Message-ID: <8760sv3atk.fsf@web.de> References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" X-Trace: ger.gmane.org 1467007724 23538 80.91.229.3 (27 Jun 2016 06:08:44 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 27 Jun 2016 06:08:44 +0000 (UTC) Cc: guile-devel@gnu.org To: arne_bab@web.de Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Sun Jun 26 23:22:25 2016 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1bHHVX-0002jM-WE for guile-devel@m.gmane.org; Sun, 26 Jun 2016 23:22:24 +0200 Original-Received: from localhost ([::1]:55300 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bHHVX-0003QH-5h for guile-devel@m.gmane.org; Sun, 26 Jun 2016 17:22:23 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:38774) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bHHVI-0003QA-IL for guile-devel@gnu.org; Sun, 26 Jun 2016 17:22:09 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bHHVE-0003Ga-9T for guile-devel@gnu.org; Sun, 26 Jun 2016 17:22:07 -0400 Original-Received: from mout.web.de ([212.227.17.12]:58057) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bHHVD-0003GV-Ui for guile-devel@gnu.org; Sun, 26 Jun 2016 17:22:04 -0400 Original-Received: from fluss ([85.212.83.63]) by smtp.web.de (mrweb101) with ESMTPSA (Nemesis) id 0LaTid-1blyg33zWJ-00mGxZ; Sun, 26 Jun 2016 23:22:01 +0200 User-agent: mu4e 0.9.16; emacs 24.5.1 In-reply-to: X-Provags-ID: V03:K0:Fd9soV5SU5C1t2sz9W2W8LKRT5S8+oG+76OZffLznxmYjs4vsy5 fXrYBXzyz04r6j0AtEc0zHNKUQ2XoN7TNtGR8Gyr/YjfKRgOwcTZjm1uHeQ8rrx1HjnGOaU nvgmmJ0ArrJQRLG3vl9Tf2cA/HzZikroHHQBigkIbeqRbbc2PD8ZDxRy31aSsSFHDt7waLC xjX24XdX5aabFykh3/TdQ== X-UI-Out-Filterresults: notjunk:1;V01:K0:4RGzDBkAC3A=:ebdj1aSRWfrrTceRA1CbZ1 YySRwRT6I/+FG8T027WCp9vuIyAcKb43gpTuzhxOkmsdwmFQ5xtwXXziK46+33rcNdhnImMEy r5YmXPOO8T/DZuWQKND+zEBB4zJZPFaYCPU1Dg9JuFroXvlX0ocjLFwFKj1LFK7PeNDUoy7yU FULU75ydlM2pXEXVgIEg3UqZpqXtNEw9FEgTzjbHb3+lLIr9x78IeEYLWEfBQEbXo9b8jv2LH iCNI2yKOA2g2ggafBsRc5SjOrAVrI5j/AQU+daTtnVQOg+pFKje1XpVgbhvGi4JkWqblRP7x+ NIwIsqGiV2OK3UapH4b2SMf2Y7tPEPMARvz7I70AvL31Ub35Ju8is6znmX+vpQOYSe+Nijmb6 Ccx5JaltE73+CJSA1/6W9XxB0nKlC11xX6W3GZc2L6OGnNUUvSf3m+5kG/xG+gfZcd6WLj2e4 HaCd39rzxha009qRpH00SSOHPdWCY9ufr2XU3GS38macclImU9m76dyou2BqY+z/Q5rWv8gkA 8PbAZ4R5EG7XHbkE0rA6RPCDbTXFoKx5DfQsrrfsUmmIsIvWK4zP7jdQlwIWZYl00E4FAbPu6 y0l72EcidQF4t8/zAR4thRCFNdwddy6/17hGYeTx9fgf08NuQ52vRu22wdZtXBq4L9nhKTDKN ce3s2WXTlXdEBN7l5xcpoZO7W78IIZ1cuJtdABvK4DTO/Yt4G3sUfe8UV2jMEUhQkZCxFupeN +quEAGnb6Q7JgAnHzzRjzzMddsol5nsLYvFJykII7cb7DpaKpdBqLxOwxf4= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] 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:18443 --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Ping :) (this change adjusts info documentation and adds examples with additional options for using Guile in shell scripts) arne_bab@web.de writes: > doc/ref/guile-invoke.texi | 15 ++++------ > doc/ref/scheme-scripts.texi | 62 ++++++++++++++++++++++++++++++++++++++= +++++++ > 2 files changed, 68 insertions(+), 9 deletions(-) > > > # HG changeset patch > # User Arne Babenhauserheide > # Date 1463602731 -7200 > # Wed May 18 22:18:51 2016 +0200 > # Node ID e5938da9b89fcee1936487df32fb649135d8a94c > # Parent 4f269918e38cd48905546c485173c4f9dbfa0717 > doc: describe the -e (module) shorthand as on equal footing with (@ ...) > > diff --git a/doc/ref/guile-invoke.texi b/doc/ref/guile-invoke.texi > --- a/doc/ref/guile-invoke.texi > +++ b/doc/ref/guile-invoke.texi > @@ -102,15 +102,12 @@ that is defined in the script. It can a > @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 > --- 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 @@ 1 > 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 I just spotted a bug here: should be /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" =2D-=20 Unpolitisch sein hei=C3=9Ft politisch sein ohne es zu merken --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBCAAGBQJXcEd4AAoJEBPvjUUkA8Prri4P/3CbT5NmWQvbYUsWXlY0xiYv 62l9Zzf/4QQOog4qgrDbreTplHvjkEAecHmBJUUD1mrJzMy2XIpxqTW5NLdZl01Z w0KnCPXkvfChHPkeQQ4VRPExW96IEywpCBe61rkqYiDtUo+qNf2AxvD7OSnShckW 0dW+g975P8qNYu3+gCDmSDlP4d6tI6Zqr2AM4Q16yU3BWu0odAtp/etSxprPg85Q 8nHP4GOUuwLTvDhzBzyTxPuqhWSIaDKDJLuU+P1sCcddv6VheFeImhAM6FF7qh8M pWphbHRtnlNQRODHWcfTAM09OoFey/OnBCQe342S1+9pc4kvehpkP1JLS4bxEgy0 gYpMeQx4HgOQvKF+a9qYqFCYpfebQHGHi0iV8XQTSAG0JbKPTBWeCD3DRvFYYZHc XhsuiawUqT5SbAGOYbksCMFedOLqW4/f7dRtKvJizXYiMQq5Ys4nTHT6XFFOFSoX 5bogAtYbnB+sBTRppmZe+iL8XwSglorhOmJ9H5sJjgwuyQ8LglQAqSLdEnYnMhAW SFN//IamoEkByhC/G3P3IdKB5pvH2Q1MT/EyST9ziZiSYROZ3d8y3WMXDLEFRBuW XtCLMBQfd07s3+56CAspPU2Al+z1KBM7qUprEgsELLgPfA8++Uwc++rlmEPjr7D4 SBwmyWCejXMeJSd3Zm+x =CpJ4 -----END PGP SIGNATURE----- --=-=-=--