unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Stefan Israelsson Tampe <stefan.itampe@gmail.com>
To: Andy Wingo <wingo@pobox.com>
Cc: guile-devel <guile-devel@gnu.org>
Subject: Re: splicing macros
Date: Fri, 8 Feb 2013 21:53:11 +0100	[thread overview]
Message-ID: <CAGua6m2u6AbscyqzTOWB1QJ+3rUVOWy+qexT8CixVt33AhBQ1Q@mail.gmail.com> (raw)
In-Reply-To: <87a9rv9bgt.fsf@pobox.com>

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

Hi,

Here is a git-format-patch of some docs for the ck macro.
enjoy!




On Sun, Jan 27, 2013 at 11:17 AM, Andy Wingo <wingo@pobox.com> wrote:
> On Sat 26 Jan 2013 14:03, Stefan Israelsson Tampe <stefan.itampe@gmail.com> writes:
>
>> I will assume that you are familliar with th ck macro, included in
>> recent guile releases or else consider looking it up at
>>
>>   http://okmij.org/ftp/Scheme/macros.html
>
> It does not seem to be documented in Guile's manual.  Want to write some
> documentation? :)
>
> Andy
> --
> http://wingolog.org/

[-- Attachment #2: 0001-doc-ref-api-macros.texi-added-documentation-for-the-.patch --]
[-- Type: application/octet-stream, Size: 2564 bytes --]

From c0e4a806bda68dc3b645e17e2475929d2cb0dfad Mon Sep 17 00:00:00 2001
From: Stefan Israelsson Tampe <stefan.itampe@gmail.com>
Date: Fri, 8 Feb 2013 21:42:38 +0100
Subject: [PATCH] * doc/ref/api-macros.texi: added documentation for the ck
 macro

---
 doc/ref/api-macros.texi |   46 ++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 46 insertions(+)

diff --git a/doc/ref/api-macros.texi b/doc/ref/api-macros.texi
index 347d025..1f9e645 100644
--- a/doc/ref/api-macros.texi
+++ b/doc/ref/api-macros.texi
@@ -44,6 +44,7 @@ languages}, or EDSLs.}.
 * Syntax Parameters::           Syntax Parameters.
 * Eval When::                   Affecting the expand-time environment.
 * Internal Macros::             Macros as first-class values.
+* Ck macro::                    Applicative evaluation order macro facility.
 @end menu
 
 @node Defining Macros
@@ -1160,7 +1161,52 @@ which one may ask the docstring. That's the whole reason this section is
 documented. Actually a part of the result of @code{macro-binding}.
 @end deffn
 
+@node Ck macro
+@subsection The Ck macro
 
+@deffn {Syntax} ck state expression
+The @code{ck} macro is a facility that simulate function applicative expansion 
+order for the scheme macro system. It does so by introducing a few conventions. 
+First every expression of the form @code{(quote x)} will mark x as the result
+of the expansion of that argument and stop try expanding. Secondly every macro 
+have to use as first argument, the state and then concatenate the actual 
+arguments. Thirdly it have to explicitly invoke the @code{ck} macro at start 
+and also at every continuation when a resulting expansion have finished. To 
+start the expantion use @code{(ck () expr)}.
+
+@example
+(use-modules (system base ck))
+
+;;note
+;; 1) The use of '... to indicate a value
+;; 2) How we continue with issueing (ck s ...) at the end of expansion
+;; 3) How macros applications inside of the ck macro does not have explicit 
+;;    s (That's added later on)
+
+(define-syntax c-cons 
+  (syntax-rules (quote)
+    ((_ s 'x 'y) (ck s '(x . y)))))
+
+(define-syntax c-map
+  (syntax-rules (quote)
+    ((_ s 'c-f '(x . l))
+     (ck s (c-cons (c-f 'x) (c-map 'c-f 'l))))
+    ((_ s _ '())
+     (ck s '()))))
+
+(define-syntax c-f 
+  (syntax-rules (quote)
+     ((_ s 'x)
+      (ck s '(* x 10)))))
+
+
+;; And to show the macro in action write
+
+,exp (ck () (c-map 'c-f '(a b c)))
+
+$1 = ((* a 10) (* b 10) (* c 10))    
+@end example
+@end deffn
 @c Local Variables:
 @c TeX-master: "guile.texi"
 @c End:
-- 
1.7.9.5


  parent reply	other threads:[~2013-02-08 20:53 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-26 13:03 splicing macros Stefan Israelsson Tampe
2013-01-27 10:17 ` Andy Wingo
2013-01-28 11:27   ` Stefan Israelsson Tampe
2013-02-08 20:53   ` Stefan Israelsson Tampe [this message]
2013-04-29 20:46     ` Fwd: " Stefan Israelsson Tampe
2014-03-20 20:32     ` Andy Wingo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAGua6m2u6AbscyqzTOWB1QJ+3rUVOWy+qexT8CixVt33AhBQ1Q@mail.gmail.com \
    --to=stefan.itampe@gmail.com \
    --cc=guile-devel@gnu.org \
    --cc=wingo@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).