From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Michael Heerdegen Newsgroups: gmane.emacs.help Subject: Re: problem with macro definitions Date: Tue, 09 May 2017 16:16:22 +0200 Message-ID: <87tw4ut8sp.fsf@drachen> References: <20170427224407.GA5655@workstation> <878tmjr1ry.fsf@drachen> <20170429160632.GA3291@workstation> <20170509081435.GA3514@workstation> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1494339482 19451 195.159.176.226 (9 May 2017 14:18:02 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 9 May 2017 14:18:02 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue May 09 16:17:58 2017 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d85xd-0004w9-GY for geh-help-gnu-emacs@m.gmane.org; Tue, 09 May 2017 16:17:57 +0200 Original-Received: from localhost ([::1]:37505 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d85xj-0001zT-4o for geh-help-gnu-emacs@m.gmane.org; Tue, 09 May 2017 10:18:03 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:42922) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d85w5-0001Ja-WE for help-gnu-emacs@gnu.org; Tue, 09 May 2017 10:16:25 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d85w2-0003O7-Ph for help-gnu-emacs@gnu.org; Tue, 09 May 2017 10:16:21 -0400 Original-Received: from mout.web.de ([217.72.192.78]:55593) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1d85w2-0003Nw-EH for help-gnu-emacs@gnu.org; Tue, 09 May 2017 10:16:18 -0400 Original-Received: from drachen.dragon ([84.63.126.150]) by smtp.web.de (mrweb101 [213.165.67.124]) with ESMTPSA (Nemesis) id 0MRl5x-1daNFh1CDR-00Svsd; Tue, 09 May 2017 16:16:16 +0200 In-Reply-To: <20170509081435.GA3514@workstation> (hector's message of "Tue, 9 May 2017 10:14:35 +0200") X-Provags-ID: V03:K0:MRFISEoRiNgTbOk92CrqiegwYJFddJBE5LKHjje2RmPmWVYnbV2 CERuEoRuuFHUaGMWROGqW8c6zcCvRq6xiag1zYWf34IuZcB76bUaADaqNo5Uyk55BneO1AJ ByNwGWc/YkqeeZ4aGzYWx1Ov7jpGhKOHmIn7qP3QZZ/+KguNJ+DJQDw9pdaYUaHxXuXW//g nlB5EZxlpd6+POw5l1hHA== X-UI-Out-Filterresults: notjunk:1;V01:K0:fSTUh3XzQzE=:dupH29r+I4wPCXMDWSo+92 1TQHt05UI4EZ/d+6qowN1OOiqxjYtAs8GWU+zyiQOv0EMoc/igCMDKm9hPFMu5BdQvsk3oN96 g2GFUWa3JWY5Q9Eu5h8qH+paMwnLWHX6aKWBFkr41znS27S8JxEVV4BGUub31qf6eal1i0RId af57ujqz7yCdywJkBCinGRkecZ1dozsrhchRb2ZJMiGguA7pX59VL1Kv5rDNQ1GwrnlC1nrld smF0evdctnGkdCitElvK8f8zQR2cQ0EKf9P1PSegzHvflc5mQLLCTUdRXe2HJiX36sikDrLUc rzFWAX0WQy11Is1MGSVfZGjq8dM65uFC/fPWQSfBduDn5aOF22wHI+loIwhOjKCtOLbJc95HN kMOaxTvqcZDu3uFDZDG0R2dfc11NM0IwlOMB0N4vs/su9aTj+hiM4OcjufMbQ9hsPU8d25KEQ UxoUKGbpKrUn2Z1jErTvd9Q2SgFbyf6HgPSS4B5MgxybwMosBjDQH2Yz0DXzD5CE+WG698ZhQ WvNOdW3XIi0ivwXrZkRnuaFgPfc9e4/9kBB3J5IUl40YZpfpZTHrAs6ccEf5skPbWW+dtlOnn Kp+LUMJ1fZiHbzwHoqybyqvpU68pOJA63/aPMGYC6MrR4BIjgbClNdMEFc4jsBs4G6eLmZcpq bsR7Z0/dZNfbOfsNyomb1ELSaBT8k+VV8tN7j70XLnIeJUj38SG7Oy6xwnuxuAKl8fYJamdB3 YtvIpNvy2jF9UeMGWdDdU5PcfZZGGmZ9Ii0ID8wRLSVRP2/DEeamlAnHLqnPDaCGkFeAfR4I X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 217.72.192.78 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:112980 Archived-At: hector writes: > I did it. This is what I meant: > > (defmacro idx (list needle) > (let (found > (haystack (eval list)) > (idx 0)) > (while (not found) > (when (eq (car haystack) needle) > (setq found idx)) > (setq idx (1+ idx)) > (setq haystack (cdr haystack))) > found)) > > The macro expansion is just a number. Yes, that's true now. > I'm not quite sure what the "(let ((haystack (eval list))))" does but > it works. A macro doesn't evaluate its arguments. Normally, arguments are evaluated when the expanded code (with argument expressions "pasted in") is run. You want to do the whole calculation at compile time, and you want to allow LIST to be an expression (known at compile time), so you need to evaluate it explicitly to get a list value. The same applies to the NEEDLE argument btw. Michael.