From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Drew Adams Newsgroups: gmane.emacs.help Subject: RE: [External] : Re: Why is defun not executed during load-file? Date: Mon, 31 May 2021 05:05:57 +0000 Message-ID: References: <87k0nfesns.fsf@zoho.eu> <87mtsbd31w.fsf@zoho.eu> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="3566"; mail-complaints-to="usenet@ciao.gmane.io" Cc: "Help-Gnu-Emacs \(help-gnu-emacs@gnu.org\)" To: Emanuel Berg Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Mon May 31 07:07:00 2021 Return-path: Envelope-to: geh-help-gnu-emacs@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 1lna8g-0000lG-K4 for geh-help-gnu-emacs@m.gmane-mx.org; Mon, 31 May 2021 07:06:58 +0200 Original-Received: from localhost ([::1]:51642 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lna8e-00087u-P6 for geh-help-gnu-emacs@m.gmane-mx.org; Mon, 31 May 2021 01:06:56 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:37858) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lna7u-00087h-5i for help-gnu-emacs@gnu.org; Mon, 31 May 2021 01:06:10 -0400 Original-Received: from aserp2130.oracle.com ([141.146.126.79]:41084) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lna7o-00020S-Qk for help-gnu-emacs@gnu.org; Mon, 31 May 2021 01:06:09 -0400 Original-Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 14V55CV5069030; Mon, 31 May 2021 05:06:01 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : references : in-reply-to : content-type : content-transfer-encoding : mime-version; s=corp-2020-01-29; bh=6PUkhVjhywFCKZG3NU30FPxInWzBpKD6Kz0vRFPMlA4=; b=nXwKVTd0E0Yn2NTfCtGyURwRZPeHzlhIalfHoXAAXEPwyD86UTEzP6Z/BdLK/7lSa0Qn HmaRSi0BLowDIhE9tW/Ucj0qUxBlTeTT/1F59yLPaJNrVk+FiKJ5+j81xZrZjSBUV4lj qPdOX262PVMU6Wq5Sxw3WfT/ZQJrjdbVebjz62Kjxx6LZgOqDLxSUgs0osQKBp1zOSQN iAR99Juh2jujUkrCuLK6aS/Fj6UWwFWpU6ou8jep6IKcqInxUlUIuY9hmaXgFkkICWIV rkDNvgotPklRVlQuOi+anMzzdclYkchsmQu8qSbw+V3qVk7BA8BkILBgk4edHotu7V2t wg== Original-Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by aserp2130.oracle.com with ESMTP id 38ub4cj28c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 31 May 2021 05:06:01 +0000 Original-Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 14V4uVYT025512; Mon, 31 May 2021 05:06:00 GMT Original-Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2177.outbound.protection.outlook.com [104.47.56.177]) by userp3020.oracle.com with ESMTP id 38uycq2njd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 31 May 2021 05:06:00 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WQAWjL62pim0ctf9IB8R4r2KaU8srPGxn48DjYVFFLXAyOv7OIkoA879P3zz3nWqEja3UaP5aa9KLzXhM/c9b88yO6NxWvEcuujpCnfMyxRpKcg/v1RRCf7CVFS3LSPx2J9/fh41qeeovSXekB9wR/4xcyEmeKvtxEXkvv43XH1tAdUpDuiAGvBBMqrq0c00sXf6mQw4mBbRUeEheW5bssOSGL2XrReRFIxzRJLdlneJSLeFSThnbHqHqNWQj7SPsY0ZZk00pXLvvPW3jlR7QUutDi/kYwUu3uLCx54FcUciIg36b1aDx7bvVO70Sj3N0Y1Ck57mpo1esvjJy8/aUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=6PUkhVjhywFCKZG3NU30FPxInWzBpKD6Kz0vRFPMlA4=; b=NccJkcpQvZQAwcFuWjOERO2vjhvLs/7Lfv++TsU8b/azr9EfubHjS1LZaIz0w5GpwG+kd9vKQXvMx4vAZ3VpCsCWajzFuKCPh689nRtNFFiJg7IYH3pksqnnHTr7YR4Q9SZas29e+ITUhJcXPm1imUDMZEkETIF9ZH6S3AqpWkchglrlxcJbMUxqf4575nEg5hQAY+IxjEMOJ0cEhKHWVRFBWEl2A3bUUGldl+8dHl9+WaxGjKW2Rzm3ImhA/ctkSSzQysGaRHR+Pppaz1DSHVvcJlv3hlhoylyVHChOBYoYoqFRnsft6GaQGa8OFcrb77a+l+U4OD7W3MiFTjhPBw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=6PUkhVjhywFCKZG3NU30FPxInWzBpKD6Kz0vRFPMlA4=; b=Ku3ckYILcPX2oKBl3DaeVmHxDOjAwvjT1w8y7Tz7w4iHWWhl/AaSohIQKdsH0i2AbpbiwWIT/K/17bPBtApNnqxO6twbvGvXZsBrnBepj5yKm7ZQfeWp+S8SVq3YpRXBiIQOht5VtOn0HaHirIeetedgFdmP4cRIfpMtY6/2Z/k= Original-Received: from SA2PR10MB4474.namprd10.prod.outlook.com (2603:10b6:806:11b::15) by SN6PR10MB2480.namprd10.prod.outlook.com (2603:10b6:805:4f::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4173.22; Mon, 31 May 2021 05:05:58 +0000 Original-Received: from SA2PR10MB4474.namprd10.prod.outlook.com ([fe80::2109:9725:fd4a:6494]) by SA2PR10MB4474.namprd10.prod.outlook.com ([fe80::2109:9725:fd4a:6494%6]) with mapi id 15.20.4173.030; Mon, 31 May 2021 05:05:58 +0000 Thread-Topic: [External] : Re: Why is defun not executed during load-file? Thread-Index: AQHXVciOVoFI9KsrhUmR9fhIpvrNCar896YA In-Reply-To: <87mtsbd31w.fsf@zoho.eu> Accept-Language: en-US Content-Language: en-US authentication-results: zoho.eu; dkim=none (message not signed) header.d=none;zoho.eu; dmarc=none action=none header.from=oracle.com; x-originating-ip: [73.170.83.28] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 314b960b-2b24-4fc1-3ae1-08d923f1c6de x-ms-traffictypediagnostic: SN6PR10MB2480: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:7219; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: BibDSrcb7mDLE0coOnP4LfoNe3DJbSdCD3PRQoJxdhn/nW0DpB0tWS2GZy0D2C0xqmthS9EyZcEof7P3snotafyKU1pBTa95uIjAnXKEJ07/dfSMi6fR1WovyUagSunOssk1w9wFsb9hk9Eud0F9q5aIMba3pgmQEO5cmH2r4reOmsOGraFYI+5R3A4w0ILBnZPuCqTyU8uQ1rc2ffHllrM4rtexZkjJQlKkvk3DV+OQsuuDTC4ibB5smQe8cVZ2exlyEQERp3ZpA+q6zEGgmEIsQay0BkTSQ9bZlkIkivuTBna0ozHIhH0gLVUkNWaYPTpwmnW+00gUbQ3jWQq6vpk6YY0b/tQzxoI3nDXOuLxAmrq0TMi52UIr2iXQ34AFVVoLZs7zvn/Fc0E/JyUFIXuy12aKceg2ytDwb7AmQt2dR+/H7FJ+q+X52VUVRBkxhmcLFw7oUeXlgXllKiZZHE77274FPhcYUi75L9lk1lVmJbpci4rJWduum87jVg9W4pIO/dBEzbO+fxvF86z78mRDMn3I5iYXVj/oXwa6hDwyZPrlC9oqFkkungjytk4qza/+lO0JiOoRl7lfz1iYZGWFuErVoIIb0bjiTakv4Qc= x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SA2PR10MB4474.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(366004)(39860400002)(376002)(136003)(396003)(346002)(55016002)(122000001)(478600001)(8936002)(38100700002)(2906002)(33656002)(44832011)(316002)(5660300002)(9686003)(71200400001)(52536014)(8676002)(26005)(86362001)(83380400001)(186003)(4326008)(66946007)(66476007)(76116006)(66446008)(64756008)(66556008)(6916009)(7696005)(6506007); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata: =?us-ascii?Q?I4IDDivmHOBIKtl8QbsLCMkIVJmbBPzpWX8xh78jc5P1NoWoZcMHanvyXDZW?= =?us-ascii?Q?aUbC/+52OpDYQbcNmUCYVrzxn8he9AN2qqWMSL1TiY4rv/2qEAoP/AeyQ/xt?= =?us-ascii?Q?kdn/O3FY5YYfSnluSJESDrRgrGP1W1A90rGNHpESdGkLu+E/JMbisoSSwRWH?= =?us-ascii?Q?mJg5GyJ+7+zA7xyX3QwbmVBOZhxKgbWBRn0CFPPiOx8eQTjQknka7X5Zxg+P?= =?us-ascii?Q?Rhyz/tlowVpOYhhqUT5vTNeQUmE1k7ZLj5pwSjrmqTnJjUS2XZyXCM355E2r?= =?us-ascii?Q?FwmAvsO0Apr18B/4pkdfPrvClCbC6HucL9lss8i6LSPFclhuvJ03kBzconb0?= =?us-ascii?Q?wjuOTbDFiWg/Ql0BX5jrUumQbxXF8yOufuXS/NIcHQR5HbM5lPCsl4mcUtrb?= =?us-ascii?Q?gt9pCxzEMsls9hlWiz/PkCMZUcXk6Muh1MEnGwpTNwH82ZsOEV8dVQEW9UeF?= =?us-ascii?Q?Rs3sXjwpKS09CTAz6WgkQXt70xphghR6J566ekMKkyc6TQFyKmm9pP1d21bn?= =?us-ascii?Q?jlYHBRksHOOS1poKOuFW32STtHE6Iprt5bIpE8p47gTWq0gRCP5EOaX+zG/D?= =?us-ascii?Q?OwC7FfM+jeu/4nnIbY+6j3r+lNPQUfEIRbsQ8ENlRehDm453BCJIafFTUWii?= =?us-ascii?Q?fxH4 x-ms-exchange-transport-forked: True X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: SA2PR10MB4474.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 314b960b-2b24-4fc1-3ae1-08d923f1c6de X-MS-Exchange-CrossTenant-originalarrivaltime: 31 May 2021 05:05:57.9532 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: vC3WJjjlH56qRGRe1uYAba1nz9/EdlUiM8qL6x7GVtcpcCJW0dFN3J7qwVKm6Ta0NH6AYStR7BbBM23ObgHrzA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR10MB2480 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=10000 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 spamscore=0 malwarescore=0 phishscore=0 mlxlogscore=869 suspectscore=0 bulkscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2105310037 X-Proofpoint-GUID: M55rhUB_aEqHdSzwgwCL3u88OhIbPAbC X-Proofpoint-ORIG-GUID: M55rhUB_aEqHdSzwgwCL3u88OhIbPAbC X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=10000 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 mlxscore=0 mlxlogscore=999 malwarescore=0 bulkscore=0 phishscore=0 lowpriorityscore=0 clxscore=1015 impostorscore=0 adultscore=0 suspectscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2105310038 Received-SPF: pass client-ip=141.146.126.79; envelope-from=drew.adams@oracle.com; helo=aserp2130.oracle.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.23 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-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:130385 Archived-At: > >> Also, writing macros compared to writing functions > >> typically involves more bugs... > > > > Why do you think so? [...] >=20 > Maybe because it involves an extra layer, writing something > that will write something that will do something instead of > writing something that will do something... >=20 > Just keep on adding layers. Write something to write something > to write something ... etc. It gets more difficult for each > level added, is what we think. Fair enough; reasonable argument. But I still think the perceived difficulty comes from relative lack of practice. There are only 2 levels/layers involved. And they're completely separate: (1) macro-expansion of a sexp to a sexp, and (2) evaluation of the sexp resulting from #1. You write lots of Lisp functions. And you no doubt think nothing of adding "layers" by having a function that calls a function that calls a function... Even inhibiting evaluation with `quote' here and there doesn't seem weird, once a novice practices a bit and gets used to it. But all of that is (can be) really quite complex. It's just that you do that all the time - you're used to it. You don't write Lisp macros all the time. ___ The macro-expansion step is the only part that's a bit unusual - it's different from most of the Lisp code you write. Think of that step as just replacing one sexp by another. The input sexp has the form of a Lisp function call: a non-empty list whose car is a symbol. The output is normally a sexp of the same form, but it need not be - it can be any Lisp value (any list, vector, string, symbol, number, buffer, frame, syntax table, keymap,...). As far as step #1 is concerned, its result need not even be something that can be evaluated - or even read - without error. And you have Lisp completely at your disposal, for creating the output sexp, given the input sexp. ___ Once you have the macro-expansion step defined, the job's typically done. What's left is to verify that the output sexp _evaluates_ to the result you want - and that, for every possible input. That is, because the result of macro-expansion (#1) is typically evaluated, you do have to worry about that evaluation step (#2), yes. But if you only ever used `macroexpand' of sexp to sexp to sexp to sexp,... then you wouldn't need to bother with that worry. You'd just be transforming one list with a symbol car to another, to another, to another,... Macro-expansion isn't evaluation; it's reduction. Lisp evaluation rules don't apply to producing the output sexp from the input sexp. What rules do apply? Whatever rules you like. The only rule underlying it all is that the input needs to be a list with a symbol car. For those used to purely functional programming, that's all macro-expansion is: just reduction - term rewriting. You can look at it as a rewrite rule from input patterns to output patterns. But the rule can be implemented any way you like, using any Lisp code.