From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: ludo@gnu.org (Ludovic =?iso-8859-1?Q?Court=E8s?=) Newsgroups: gmane.lisp.guile.user Subject: Re: Expanding macros Date: Wed, 26 Sep 2012 23:54:46 +0200 Message-ID: <873924phzt.fsf@gnu.org> References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1348731357 9282 80.91.229.3 (27 Sep 2012 07:35:57 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 27 Sep 2012 07:35:57 +0000 (UTC) To: guile-user@gnu.org Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Thu Sep 27 09:36:02 2012 Return-path: Envelope-to: guile-user@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 1TH8dc-00056y-9v for guile-user@m.gmane.org; Thu, 27 Sep 2012 09:36:00 +0200 Original-Received: from localhost ([::1]:56004 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TH8dX-00049q-96 for guile-user@m.gmane.org; Thu, 27 Sep 2012 03:35:55 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:51751) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TGzZS-0002K9-V0 for guile-user@gnu.org; Wed, 26 Sep 2012 17:55:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TGzZR-0005I2-JX for guile-user@gnu.org; Wed, 26 Sep 2012 17:55:06 -0400 Original-Received: from plane.gmane.org ([80.91.229.3]:45176) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TGzZR-0005FX-Dm for guile-user@gnu.org; Wed, 26 Sep 2012 17:55:05 -0400 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1TGzZQ-0001Lk-2X for guile-user@gnu.org; Wed, 26 Sep 2012 23:55:04 +0200 Original-Received: from reverse-83.fdn.fr ([80.67.176.83]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 26 Sep 2012 23:55:04 +0200 Original-Received: from ludo by reverse-83.fdn.fr with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 26 Sep 2012 23:55:04 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 31 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: reverse-83.fdn.fr X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: 5 =?iso-8859-1?Q?Vend=E9miaire?= an 221 de la =?iso-8859-1?Q?R=E9volution?= X-PGP-Key-ID: 0xEA52ECF4 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 83C4 F8E5 10A3 3B4C 5BEA D15D 77DD 95E2 EA52 ECF4 X-OS: x86_64-unknown-linux-gnu User-Agent: Gnus/5.130005 (Ma Gnus v0.5) Emacs/24.2 (gnu/linux) Cancel-Lock: sha1:r+jS04SLg9zAbqluIOowFGrNuvo= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 X-Mailman-Approved-At: Thu, 27 Sep 2012 03:35:51 -0400 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Original-Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.user:9595 Archived-At: Hi, Panicz Maciej Godek skribis: > is there any legitimate way to expand the scheme macros > to the scheme code in guile 2.0? > The macroexpand procedure seems only to compile the code > to the tree-il language (no matter whether 'e, 'c or any other > symbol is passed as a second argument): > > (macroexpand '(define (f a b) (list a b)) 'e) > ; ===> # #f #f #f () (a-4236 b-4237)) (apply (toplevel list) (lexical a a-4236) > (lexical b b-4237)))))) There’s the ,expand command at the REPL. It’s implemented like this: (define (repl-expand repl form) (let ((from (repl-language repl)) (opts (repl-compile-options repl))) (decompile (compile form #:from from #:to 'tree-il #:opts opts #:env (current-module)) #:from 'tree-il #:to from))) Psyntax, the macro expander, returns tree-il, hence the need to go through ‘decompile’. Thanks, Ludo’.