From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: David Kastrup Newsgroups: gmane.comp.gnu.lilypond.devel,gmane.lisp.guile.devel Subject: Re: definitions in macros? Date: Sun, 22 Mar 2020 22:09:25 +0100 Message-ID: <87v9mw9jwa.fsf@fencepost.gnu.org> References: Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="42840"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: lilypond-devel , Guile Devel To: Han-Wen Nienhuys Original-X-From: lilypond-devel-bounces+gnu-lilypond-devel=m.gmane-mx.org@gnu.org Sun Mar 22 22:09:41 2020 Return-path: Envelope-to: gnu-lilypond-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jG7qm-000B3V-NN for gnu-lilypond-devel@m.gmane-mx.org; Sun, 22 Mar 2020 22:09:40 +0100 Original-Received: from localhost ([::1]:49814 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jG7ql-00074G-Bu for gnu-lilypond-devel@m.gmane-mx.org; Sun, 22 Mar 2020 17:09:39 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:41926) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jG7qb-000745-Cg; Sun, 22 Mar 2020 17:09:30 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:40495) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1jG7qb-0006jl-9a; Sun, 22 Mar 2020 17:09:29 -0400 Original-Received: from x4e313926.dyn.telefonica.de ([78.49.57.38]:41120 helo=lola) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1jG7qa-00072U-IE; Sun, 22 Mar 2020 17:09:29 -0400 In-Reply-To: (Han-Wen Nienhuys's message of "Sun, 22 Mar 2020 20:07:11 +0100") X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-BeenThere: lilypond-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Discussions on LilyPond development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: lilypond-devel-bounces+gnu-lilypond-devel=m.gmane-mx.org@gnu.org Original-Sender: "lilypond-devel" Xref: news.gmane.io gmane.comp.gnu.lilypond.devel:74341 gmane.lisp.guile.devel:20456 Archived-At: Han-Wen Nienhuys writes: > Hi there, > > in my quest to get lilypond working with GUILE 2+, I've hit another > stumbling block. > > In order to make compilation with GUILE 2+ working, we have to move > away from runtime symbol definition (ie. module-define! calls). > > In the code below, it looks like only one of the two definitions in > the body of my-macro-new takes effect. Is this expected, and if so, > why? > > (defmacro-public my-macro-old (command-and-args . definition) > (module-define! (current-module) 'x1 "I am X1\n") > (module-define! (current-module) 'x2 "I am X2\n")) > > (defmacro-public my-macro-new (command-and-args . definition) > `(define p "i am P\n") > `(define q "i am Q\n")) This is very much expected. The macro body contains two side-effect free expressions (namely quoted lists) and returns the last one which is (define q "i am Q\n") This then gets evaluated at run time, defining q . You probably wanted something like `(begin (define p ...) (define q ...)) as your body (and return expression) instead. > (my-macro-old 1 2) > (my-macro-new 1 2) > (display x1) > (display x2) > (display q) > (display p) > > > thanks, -- David Kastrup