From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mailtransmit04.runbox.com (mailtransmit04.runbox.com [IPv6:2a0c:5a00:149::25]) by sourceware.org (Postfix) with ESMTPS id A92503858430 for ; Thu, 27 Jan 2022 23:57:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A92503858430 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=bothner.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=bothner.com Received: from mailtransmit03.runbox ([10.9.9.163] helo=aibo.runbox.com) by mailtransmit04.runbox.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1nDEdf-00DJTL-To; Fri, 28 Jan 2022 00:57:15 +0100 Received: from [10.9.9.74] (helo=submission03.runbox) by mailtransmit03.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1nDEdf-0006Zw-HX; Fri, 28 Jan 2022 00:57:15 +0100 Received: by submission03.runbox with esmtpsa [Authenticated ID (524175)] (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) id 1nDEdc-0004dH-AZ; Fri, 28 Jan 2022 00:57:12 +0100 Message-ID: Date: Thu, 27 Jan 2022 15:57:07 -0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.4.0 Subject: Re: "define is only allowed in a " Content-Language: en-US To: Panicz Maciej Godek , kawa@sourceware.org References: From: Per Bothner In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00, KAM_DMARC_STATUS, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_SOFTFAIL, TXREP autolearn=no autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: kawa@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Kawa mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 27 Jan 2022 23:57:20 -0000 I don't know the actual problem, but the following explains the error message. Syntax expansion (translating of S-expressions to Expression objects) is done in two interleaved phases: (1) The "scan" phase is primarily about collecting the set of names bound in a . So given something like: (define name expr) it will make a note of 'name' but it will leave 'expr' for the next phase. (2) The rewrite phase expands a single expression in the context of existing definitions. Macro expansion may happen in either phase, as needed. For example 'define' is actually a macro that expands into the more primitive '%define'. Forms at the the top-level of a have to be expanded at scan time - thus 'define' gets expanded at scan time to '%define' which then gets further processed. The 'let' form does not define new non-local identifiers, so 'let' is processed at rewrite time - and does not need any processing at scan time. 'define' (or rather '%define') needs processing at both scan and rewrite times: scan makes a note of the defined name, and converts it to a simpler form that is later processed by rewrite. It is an error for 'define' to appear in expression context, such as the following: (list (define x 10) x) That is what the error message means. Kawa will complain if rewrite is asked to process a 'define' (or '%define') form that has not been previously processed by scan. Basically, one of your macros expands to a 'define' in expression context. -- --Per Bothner per@bothner.com http://per.bothner.com/