guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: splicing macros


From: Andy Wingo
Subject: Re: splicing macros
Date: Thu, 20 Mar 2014 21:32:03 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux)

Hi,

Top-posting as it's been so long.  You know, on second thought I'm
hesitant to document this macro.  I understood it at one point but it
has totally left my head -- I can only remember so many things.  It seem
to me that the best we can do is probably pointing to Oleg's web page,
and leaving it out of the manual.  If we do put it in, it's not really a
peer of "syntax-rules", which is where you put it...  dunno.  I'm open
to other thoughts.

Sorry for the negativity!

A

On Fri 08 Feb 2013 21:53, Stefan Israelsson Tampe <address@hidden> writes:

> 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 <address@hidden> wrote:
>> On Sat 26 Jan 2013 14:03, Stefan Israelsson Tampe <address@hidden> 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/
>
> From c0e4a806bda68dc3b645e17e2475929d2cb0dfad Mon Sep 17 00:00:00 2001
> From: Stefan Israelsson Tampe <address@hidden>
> 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
>  
> address@hidden Ck macro
> address@hidden The Ck macro
>  
> address@hidden {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)}.
> +
> address@hidden
> +(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))    
> address@hidden example
> address@hidden deffn
>  @c Local Variables:
>  @c TeX-master: "guile.texi"
>  @c End:

-- 
http://wingolog.org/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]