unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* [PATCH] doc: describe the -e (module) shorthand as on equal footing with (@ ...)
@ 2016-05-18 20:25 arne_bab
  2016-06-26 21:21 ` Arne Babenhauserheide
  0 siblings, 1 reply; 9+ messages in thread
From: arne_bab @ 2016-05-18 20:25 UTC (permalink / raw)
  To: guile-devel; +Cc: arne_bab

 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 <arne.babenhauserheide@kit.edu>
# 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}.
 
-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}.
 
 @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")}.
 
+@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
 
+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
 
 @c Local Variables:
 @c TeX-master: "guile.texi"



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] doc: describe the -e (module) shorthand as on equal footing with (@ ...)
  2016-05-18 20:25 [PATCH] doc: describe the -e (module) shorthand as on equal footing with (@ ...) arne_bab
@ 2016-06-26 21:21 ` Arne Babenhauserheide
  2016-06-27  8:08   ` Andy Wingo
  0 siblings, 1 reply; 9+ messages in thread
From: Arne Babenhauserheide @ 2016-06-26 21:21 UTC (permalink / raw)
  To: arne_bab; +Cc: guile-devel

[-- Attachment #1: Type: text/plain, Size: 4802 bytes --]

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 <arne.babenhauserheide@kit.edu>
> # 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}.
>  
> -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}.
>  
>  @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")}.
>  
> +@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
>  
> +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
>  
>  @c Local Variables:
>  @c TeX-master: "guile.texi"


-- 
Unpolitisch sein
heißt politisch sein
ohne es zu merken

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 818 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] doc: describe the -e (module) shorthand as on equal footing with (@ ...)
  2016-06-26 21:21 ` Arne Babenhauserheide
@ 2016-06-27  8:08   ` Andy Wingo
  2016-07-06 21:14     ` Arne Babenhauserheide
  0 siblings, 1 reply; 9+ messages in thread
From: Andy Wingo @ 2016-06-27  8:08 UTC (permalink / raw)
  To: Arne Babenhauserheide; +Cc: guile-devel

On Sun 26 Jun 2016 23:21, Arne Babenhauserheide <arne_bab@web.de> writes:

> 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 <arne.babenhauserheide@kit.edu>
>> # 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 (@ ...)
>>

Is this an HG changeset?  I am confused.  In any case can you please
provide a GNU-style changelog.  Thanks :)



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] doc: describe the -e (module) shorthand as on equal footing with (@ ...)
  2016-06-27  8:08   ` Andy Wingo
@ 2016-07-06 21:14     ` Arne Babenhauserheide
  2016-07-07 10:19       ` Andy Wingo
  0 siblings, 1 reply; 9+ messages in thread
From: Arne Babenhauserheide @ 2016-07-06 21:14 UTC (permalink / raw)
  To: Andy Wingo; +Cc: guile-devel

[-- Attachment #1: Type: text/plain, Size: 1569 bytes --]

Hi Andy,

Andy Wingo writes:

> On Sun 26 Jun 2016 23:21, Arne Babenhauserheide <arne_bab@web.de> writes:
>
>> 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 <arne.babenhauserheide@kit.edu>
>>> # 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 (@ ...)
>>>
>
> Is this an HG changeset?  I am confused.  In any case can you please
> provide a GNU-style changelog.  Thanks :)

Sorry that I only answer now — I missed your reply until I now checked
for it when writing a comment to SRFI-138. It is a hg changeset — just
the diff with some metadata :)


Does the following suffice as ChangeLog entry?


2016-05-18  Arne Babenhauserheide  <arne.babenhauserheide@kit.edu>

	* doc/ref/guile-invoke.texi, doc/ref/scheme-scripts.texi:
	describe the -e (module) shorthand as on equal footing with (@ ...)


It’s mostly generated with hg log --template changelog -r tip.


Best wishes,
Arne
-- 
Unpolitisch sein
heißt politisch sein
ohne es zu merken

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 818 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] doc: describe the -e (module) shorthand as on equal footing with (@ ...)
  2016-07-06 21:14     ` Arne Babenhauserheide
@ 2016-07-07 10:19       ` Andy Wingo
  2016-09-29 15:14         ` Arne Babenhauserheide
  0 siblings, 1 reply; 9+ messages in thread
From: Andy Wingo @ 2016-07-07 10:19 UTC (permalink / raw)
  To: Arne Babenhauserheide; +Cc: guile-devel

On Wed 06 Jul 2016 23:14, Arne Babenhauserheide <arne_bab@web.de> writes:

> Does the following suffice as ChangeLog entry?
>
>
> 2016-05-18  Arne Babenhauserheide  <arne.babenhauserheide@kit.edu>
>
> 	* doc/ref/guile-invoke.texi, doc/ref/scheme-scripts.texi:
> 	describe the -e (module) shorthand as on equal footing with (@ ...)
>
>
> It’s mostly generated with hg log --template changelog -r tip.

Hi,

In Guile we work with git :) If you would like a patch applied, please
attach it in git-format-patch format, with the commit log in the
standard format.  Check the git logs for examples.  It's easy: just do
"git commit -a", paste in your change log with the summary line and no
indentation, then "git format-patch HEAD^".

Andy



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] doc: describe the -e (module) shorthand as on equal footing with (@ ...)
  2016-07-07 10:19       ` Andy Wingo
@ 2016-09-29 15:14         ` Arne Babenhauserheide
  2016-12-04 23:18           ` Arne Babenhauserheide
  2017-02-13 21:03           ` Ludovic Courtès
  0 siblings, 2 replies; 9+ messages in thread
From: Arne Babenhauserheide @ 2016-09-29 15:14 UTC (permalink / raw)
  To: Andy Wingo; +Cc: guile-devel

[-- Attachment #1: Type: text/plain, Size: 5586 bytes --]


Andy Wingo writes:

> On Wed 06 Jul 2016 23:14, Arne Babenhauserheide <arne_bab@web.de> writes:
>
>> Does the following suffice as ChangeLog entry?
>>
>>
>> 2016-05-18  Arne Babenhauserheide  <arne.babenhauserheide@kit.edu>
>>
>> 	* doc/ref/guile-invoke.texi, doc/ref/scheme-scripts.texi:
>> 	describe the -e (module) shorthand as on equal footing with (@ ...)
>>
>>
>> It’s mostly generated with hg log --template changelog -r tip.
>
> Hi,
>
> In Guile we work with git :) If you would like a patch applied, please
> attach it in git-format-patch format, with the commit log in the
> standard format.  Check the git logs for examples.  It's easy: just do
> "git commit -a", paste in your change log with the summary line and no
> indentation, then "git format-patch HEAD^".

Sorry for answering late. I missed your answer again (just noticed the
unresolved todo in my agenda and checked explicitly).

I now essentially typed in your commands, plus some manual patch -p1 to
use my own patch :)

Is this OK?

From 4751b9c4c85152281f0d57eda6a1c4ce50166ad4 Mon Sep 17 00:00:00 2001
From: Arne Babenhauserheide <arne_bab@web.de>
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}.
 
-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}.
 
 @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")}.
 
+@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
 
+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
 
 @c Local Variables:
 @c TeX-master: "guile.texi"
-- 
2.7.3


Best wishes,
Arne
-- 
Unpolitisch sein
heißt politisch sein
ohne es zu merken

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 818 bytes --]

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH] doc: describe the -e (module) shorthand as on equal footing with (@ ...)
  2016-09-29 15:14         ` Arne Babenhauserheide
@ 2016-12-04 23:18           ` Arne Babenhauserheide
  2017-02-07 14:16             ` Arne Babenhauserheide
  2017-02-13 21:03           ` Ludovic Courtès
  1 sibling, 1 reply; 9+ messages in thread
From: Arne Babenhauserheide @ 2016-12-04 23:18 UTC (permalink / raw)
  To: Andy Wingo; +Cc: guile-devel

[-- Attachment #1: Type: text/plain, Size: 4907 bytes --]

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 <arne_bab@web.de>
> 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}.
>  
> -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}.
>  
>  @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")}.
>  
> +@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
>  
> +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
>  
>  @c Local Variables:
>  @c TeX-master: "guile.texi"
> -- 
> 2.7.3

Best wishes,
Arne
-- 
Unpolitisch sein
heißt politisch sein
ohne es zu merken

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 800 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] doc: describe the -e (module) shorthand as on equal footing with (@ ...)
  2016-12-04 23:18           ` Arne Babenhauserheide
@ 2017-02-07 14:16             ` Arne Babenhauserheide
  0 siblings, 0 replies; 9+ messages in thread
From: Arne Babenhauserheide @ 2017-02-07 14:16 UTC (permalink / raw)
  To: Andy Wingo; +Cc: guile-devel

[-- Attachment #1: Type: text/plain, Size: 5149 bytes --]

Hi,

Any update on this?

Best wishes,
Arne

Arne Babenhauserheide <arne_bab@web.de> 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 <arne_bab@web.de>
>> 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}.
>>  
>> -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}.
>>  
>>  @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")}.
>>  
>> +@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
>>  
>> +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
>>  
>>  @c Local Variables:
>>  @c TeX-master: "guile.texi"
>> -- 
>> 2.7.3
>
> Best wishes,
> Arne


-- 
Unpolitisch sein
heißt politisch sein
ohne es zu merken

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 800 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] doc: describe the -e (module) shorthand as on equal footing with (@ ...)
  2016-09-29 15:14         ` Arne Babenhauserheide
  2016-12-04 23:18           ` Arne Babenhauserheide
@ 2017-02-13 21:03           ` Ludovic Courtès
  1 sibling, 0 replies; 9+ messages in thread
From: Ludovic Courtès @ 2017-02-13 21:03 UTC (permalink / raw)
  To: guile-devel

Arne Babenhauserheide <arne_bab@web.de> skribis:

> From 4751b9c4c85152281f0d57eda6a1c4ce50166ad4 Mon Sep 17 00:00:00 2001
> From: Arne Babenhauserheide <arne_bab@web.de>
> 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 (@ ...)

Applied with a few cosmetic changes.  Thanks!

Ludo’.




^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2017-02-13 21:03 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-18 20:25 [PATCH] doc: describe the -e (module) shorthand as on equal footing with (@ ...) arne_bab
2016-06-26 21:21 ` Arne Babenhauserheide
2016-06-27  8:08   ` Andy Wingo
2016-07-06 21:14     ` Arne Babenhauserheide
2016-07-07 10:19       ` Andy Wingo
2016-09-29 15:14         ` Arne Babenhauserheide
2016-12-04 23:18           ` Arne Babenhauserheide
2017-02-07 14:16             ` Arne Babenhauserheide
2017-02-13 21:03           ` Ludovic Courtès

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).