From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Andy Wingo Newsgroups: gmane.lisp.guile.devel Subject: Re: splicing macros Date: Thu, 20 Mar 2014 21:32:03 +0100 Message-ID: <87r45wy5ks.fsf@pobox.com> References: <5103d30a.6718700a.6306.350b@mx.google.com> <87a9rv9bgt.fsf@pobox.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1395347534 18541 80.91.229.3 (20 Mar 2014 20:32:14 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 20 Mar 2014 20:32:14 +0000 (UTC) Cc: guile-devel To: Stefan Israelsson Tampe Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Thu Mar 20 21:32:25 2014 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 1WQjdY-00048T-VJ for guile-devel@m.gmane.org; Thu, 20 Mar 2014 21:32:25 +0100 Original-Received: from localhost ([::1]:49167 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WQjdY-0003hC-IM for guile-devel@m.gmane.org; Thu, 20 Mar 2014 16:32:24 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:47612) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WQjdQ-0003RH-ID for guile-devel@gnu.org; Thu, 20 Mar 2014 16:32:21 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WQjdJ-0001Py-2U for guile-devel@gnu.org; Thu, 20 Mar 2014 16:32:16 -0400 Original-Received: from a-pb-sasl-quonix.pobox.com ([208.72.237.25]:48541 helo=sasl.smtp.pobox.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WQjdI-0001Pu-TH for guile-devel@gnu.org; Thu, 20 Mar 2014 16:32:08 -0400 Original-Received: from sasl.smtp.pobox.com (unknown [127.0.0.1]) by a-pb-sasl-quonix.pobox.com (Postfix) with ESMTP id 58935F617; Thu, 20 Mar 2014 16:32:08 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type; s=sasl; bh=F/YSvxaftDe+/3q6gKBPTTOn12g=; b=pnQhhH G3k36GNuUny3wsDN/eQKJm0MCwGA1WSUwspljdeOByavnCIPfIe/zFQtS8IACZCg 07b340tfO8R1Dewg83gj1sB4L9pWWEGOaYQWYqjHb7PjitDwN8ipenAvuspkI+uu 7Vf2yxpRIKCDESfEdv3arjZrCcfTNDcPDoQNY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type; q=dns; s=sasl; b=jFYR+Kul5LHw9rLB88C/9LdKKMw2h4hT 7dCBoV+WdiEfjvV8jEgR9pw2CKoqq2lAEOVsrKQJgDivxMs3QA8m3/2DNQ6f5cnD DSqlBTNavFzsuuWEXfyJv+XO0ebnSyfHSbpyHFTdxc5VD7/8Vm1oJCf4smBhTy2a jhtRkWuj9/g= Original-Received: from a-pb-sasl-quonix.pobox.com (unknown [127.0.0.1]) by a-pb-sasl-quonix.pobox.com (Postfix) with ESMTP id 4EC65F616; Thu, 20 Mar 2014 16:32:08 -0400 (EDT) Original-Received: from badger (unknown [88.160.190.192]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by a-pb-sasl-quonix.pobox.com (Postfix) with ESMTPSA id BC011F615; Thu, 20 Mar 2014 16:32:05 -0400 (EDT) In-Reply-To: (Stefan Israelsson Tampe's message of "Fri, 8 Feb 2013 21:53:11 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) X-Pobox-Relay-ID: B3B1FA3C-B06E-11E3-98AB-873F0E5B5709-02397024!a-pb-sasl-quonix.pobox.com X-detected-operating-system: by eggs.gnu.org: Solaris 10 X-Received-From: 208.72.237.25 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.14 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-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:16989 Archived-At: 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 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 wrote: >> On Sat 26 Jan 2013 14:03, Stefan Israelsson Tampe 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 > 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: -- http://wingolog.org/