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.devel Subject: RE: [External] : Re: Conditional binding and testing of `lexical-binding' Date: Sun, 2 Jan 2022 23:01:09 +0000 Message-ID: References: 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="17631"; mail-complaints-to="usenet@ciao.gmane.io" Cc: "emacs-devel@gnu.org" To: LdBeth Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Jan 03 00:03:18 2022 Return-path: Envelope-to: ged-emacs-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 1n49sj-0004LS-LT for ged-emacs-devel@m.gmane-mx.org; Mon, 03 Jan 2022 00:03:17 +0100 Original-Received: from localhost ([::1]:48694 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n49si-0007dj-4v for ged-emacs-devel@m.gmane-mx.org; Sun, 02 Jan 2022 18:03:16 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:48554) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n49qx-0005VL-FG for emacs-devel@gnu.org; Sun, 02 Jan 2022 18:01:27 -0500 Original-Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]:10466) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n49qq-0002zE-I7 for emacs-devel@gnu.org; Sun, 02 Jan 2022 18:01:26 -0500 Original-Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 2029l0UJ028950; Sun, 2 Jan 2022 23:01:13 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-2021-07-09; bh=509WjquzlSEL0Pl8KWTr+WOrdBpHFC9RLoqhqf26LK4=; b=faWwpJs+K8sMl5IZ+7fc+Hk0L4DUPKi5HZgYF00Ix29K6u5KQHkFkfnjdPpI5hdC8web qWDCdkpHhHKfwg59I7g99RKD07Zd0KW1DD1uRLTDiqO6idTGyksivV12Hsh0GAzd5+/r /0OHfdZ0Iaw25g2WhsWMAjaD44slvyyQKzVzk3RBImwZXomH01dkAwNuHCknUCECVKQl FvQjVl+1IQKS4XvDYb4H2EdIo2Eq6xnG0s8v1Mv6y/BMxbczUF9yuytc4qZ+WCwUa+2C 8kmT1C33nY3ohEpnX1BI/JoM4sxLQwF8gmWZtllLkMwF3+e+ffjm9tsHI0qAtvzEP1x1 hQ== Original-Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by mx0b-00069f02.pphosted.com with ESMTP id 3daeuahmsq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 02 Jan 2022 23:01:13 +0000 Original-Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 202Mpcak097366; Sun, 2 Jan 2022 23:01:11 GMT Original-Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2169.outbound.protection.outlook.com [104.47.56.169]) by userp3030.oracle.com with ESMTP id 3dac2tsj22-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 02 Jan 2022 23:01:11 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BzDo/hGFWLF4B2LDTxfiz64/6ZdXtb5uPUwRmUK+Gv53bOcoZz64u+FANuuiLLXzgA4d/VtSI10i3rsU3nfCXxtdL4ja7l6Qj0iE4EClYW9FjzMK1m7sAT3eYf41q5HipFrYC0iCVom5Y+c9ZEhu4Uwr9gGMOwM5/5pc2P0Kf4dV0DC1Ho1mdU6lJPyfSMO6Pl8/FG1C3lZbMraKYXO4Oo9+KrJ5lASkFu6FZKXXawmzvToT007S+JunFrvcFnQdE1YV13p0B8LDPoaaA8MnNYd6URMIWun5MOTL2f3CHe+PKNbMEtODKy1hXyT5zyceT3gxYSN8eKFpDGfWMGb+Eg== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=509WjquzlSEL0Pl8KWTr+WOrdBpHFC9RLoqhqf26LK4=; b=D89+gZQfWtnxFdBHsnPJ+ZJd3vEUJ0BAfZ/hdVU3mK1XAjNvlrWI1v9l7abmeGD5lkbJyDva8ZIXMSQl9ENtHqScTrDY74hBOME8E6vL6ZC1a2ZZumUYtWVpSYksq+KtT+zD6VKtXivz0w1+dE1HrH8GRKV4sirehbyOt5wZrvd8Pfnn5ILW6GrghTphMrSG0p4lnIPyWEeK8JMJZ03EY/gHaoz/kkxZHVyhPAYtdaRIN64lLxqR2G04QvsfseInkiL5CRTsiCwCWeSVET8urgb0kja8jt1g93OpW+s1p8LfXOl3JQihcW8L0Ur8wpEXpQ2hDJjDqYofhUjwzCUvng== 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=509WjquzlSEL0Pl8KWTr+WOrdBpHFC9RLoqhqf26LK4=; b=UVn5JMoAIuI4WAqU+r803aI5+AbQmSzevu7TkvFhNHvIwYTkX+aJ4RJKMvxynIuoHE5tnS8D7Gf7YAdTX7qmIsAmvv/k6z3E0LhpuKB5K8a7vcEhxkgnJBSWYRPUi80hAyPATNhMAqwQa4nbvKq/7hkV61peVKDClsor7T6QbJI= Original-Received: from SJ0PR10MB5488.namprd10.prod.outlook.com (2603:10b6:a03:37e::19) by SJ0PR10MB4495.namprd10.prod.outlook.com (2603:10b6:a03:2d6::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4844.13; Sun, 2 Jan 2022 23:01:09 +0000 Original-Received: from SJ0PR10MB5488.namprd10.prod.outlook.com ([fe80::99a4:696f:5f30:36b3]) by SJ0PR10MB5488.namprd10.prod.outlook.com ([fe80::99a4:696f:5f30:36b3%7]) with mapi id 15.20.4844.016; Sun, 2 Jan 2022 23:01:09 +0000 Thread-Topic: [External] : Re: Conditional binding and testing of `lexical-binding' Thread-Index: AQHX/9Vll+jASylD90ONpWo26FqSWqxQQGmg In-Reply-To: Accept-Language: en-US Content-Language: en-US x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: e97c0861-163f-4d4c-96db-08d9ce43c3fd x-ms-traffictypediagnostic: SJ0PR10MB4495:EE_ x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:10000; x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: Ck6qLSRPAd0WByXgPrUqc/pS4p51ARo7wylVeAmyJCj2HU3zHdw4+MS9uvYMes/k1j/B1wK3C4ohfrPbAZ6xC24TOQIerodScKtbs3hewbrp7V7AvbDK4m7khw7e7z12I4KZkSJZ3t9DbD1dOT8k5cXP7saAizaBYNSkiH6diLRMdEnTOeJbgICBrt5R6EtNjVh2Y/+tBXS1Ng9V6Z7j0Fw6TcETcTAdJnRCdYDmFnQ2Qt5TWvfQ7sQc2Clb2qfGooqNZNhp1408Z4jEZgvZLElUaKehbTUyt+syXQdWCH0nEh3bFHRLv452cOfM0raExZTmN55wnzsDDZJg9IfH20DNbGfeh6QA2XvJKC8ywKgJEty3JAJWeSp0MzCSXG0Uf2Hm0KBVA9sSfYeY2bOGk7rDiY7jHrUxPkGwLgqyuDvLxar7et/IFsazTBbpXmfVIDSTpVvfkultoJF1dyHPN2ra60V3CTj8ROueNPA1zUkJ8sAcWSErNDWv3Aqa66QdsGhrHj9BMT/KZrHwDjwVQx3CjuVo447KNaeJqE61tI8LeRgXCgjctUa3cllO6LY/4hl17Eta/f7Qf+hmyKZ8pylplNUCQaAixXVlOsWOn/VcinHZWlieqEC3WtlEj8WjhsxvvyWEMptnH/TJTOfTCXklUlILjjLrnqxggIgzOBAorsJbH9hLPrLHR4/GK7rJNPnr9nCVgAlzuVrWX4C6brVe01jvViYCy+PhN0ndy30= x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SJ0PR10MB5488.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(366004)(186003)(52536014)(66946007)(26005)(4326008)(76116006)(71200400001)(66556008)(66446008)(66476007)(64756008)(44832011)(9686003)(508600001)(7696005)(86362001)(5660300002)(83380400001)(2906002)(33656002)(38070700005)(8676002)(38100700002)(6916009)(6506007)(8936002)(55016003)(122000001)(316002)(81973001); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?e55eJTuF/6enAp+22iNQkkN5EJXGLLkmJESXgBeEk17EC4Pu/1OaflKL3tAF?= =?us-ascii?Q?8X7BFGRWIBBxbmJbr2qzDA4YZ/lMqv2bQyeyzLXMWKxmiihYz6tcjcgyxqbK?= =?us-ascii?Q?z62q0ZZLwlXDUIH5MQu0+1pzmV6617R57reELkUWTu5EhrkLsjemQGvigOWY?= =?us-ascii?Q?dQb0IROpSPix+m/z4KVCOjGlhFg6hrz8ezbbudrfehiRkS+sJs6yOUfUWcuh?= =?us-ascii?Q?TiOiHh7SoR6tlCTKlHXKjOFwuoNWjoslkJ7w4mF6Uz0IVa0haUx7dYpnzuYj?= =?us-ascii?Q?RH7EwYckyRTADlXmPj/h8Y+9xb+9W6Qc7ptlL+vnWh/TfBUdpKt033gIXOLU?= =?us-ascii?Q?D1yzs3hqdASlaWTIq+d+8YSj2A4nESNbWK5GgYKry5UDPiDnrcPkc5BLxmfF?= =?us-ascii?Q?XRTV014IWrFFdwXyLb85Tm90UgHfI7aXDiLFr92dmTCBAdNLbN1F1la/LpYE?= =?us-ascii?Q?I3PZ+9sfClPz3X/q9TdOJ0JA1Dp7XqWlvyBq55w/qnGG5ByTDhkhfnnd2JUd?= =?us-ascii?Q?QvlPmpN4O6oibaaMjG7R996yCY+eZtSD26Yk/AlwzfgQKWneNefANxCon+WG?= =?us-ascii?Q?AU62C0N732TJP2oDckjnCxZHad7HUaSrROjuV8KOQqA5iYlJPGN83DzDAqMF?= =?us-ascii?Q?sU X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: SJ0PR10MB5488.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: e97c0861-163f-4d4c-96db-08d9ce43c3fd X-MS-Exchange-CrossTenant-originalarrivaltime: 02 Jan 2022 23:01:09.4849 (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: ubrY1bhsgbbMGBViXUz6vtMBYBoVMvL0rmPHsqQDWmAdxLbv+XQHpdEQb2d/HVKriyqvyfSnMEkr5+IBFCnuYg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB4495 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10215 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 mlxlogscore=999 mlxscore=0 suspectscore=0 spamscore=0 phishscore=0 malwarescore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2201020166 X-Proofpoint-GUID: kPIWtJc5Xz1dU2-uujuRqf9PJiLQdC3x X-Proofpoint-ORIG-GUID: kPIWtJc5Xz1dU2-uujuRqf9PJiLQdC3x Received-SPF: pass client-ip=205.220.165.32; envelope-from=drew.adams@oracle.com; helo=mx0a-00069f02.pphosted.com X-Spam_score_int: -8 X-Spam_score: -0.9 X-Spam_bar: / X-Spam_report: (-0.9 / 5.0 requ) DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:283978 Archived-At: > > (if (and (boundp 'lexical-binding) > > lexical-binding) > > (lambda (y) (something x y)) > > `(lambda (y) (something ',x y))) >=20 > You may use `static-if' to benifit from > byte-compiling. I see no `static-if' in any Emacs release, from emacs -Q. (The most recent Emacs release is 27.2.) Certainly it's not present in Emacs 23 or earlier, which is where there's no variable `lexical-let'. So clearly it can't be used in Emacs 23 to test whether lexical binding is supported. I wonder whether you might have misread my post. This is about a library that intends to be usable with Emacs releases prior to Emacs 24 (where that var is introduced), as well as with later Emacs releases. This is not about _converting_ a library to always use `lexical-binding', which would only be useful for Emacs 24 and later. It's about being able to take advantage of `lexical-binding' for Emacs 24+, while still being compatible with versions earlier than 24. > > But my question is really about conditionally > > _setting_ `lexical-binding', so it can be tested. >=20 > I think the "lispy" way is to use:=20 > (provide 'lexical-binding)> and use `featurep' to test it. See above, or reread my first post. (And none of my code is providing feature `lexical-binding'. Just setting that var to t does not "provide" it as a supported feature. It's either supported by a given version of Emacs or it's not.) > A more reliable way To do what? This apparently has nothing to do with the quoted text it followed (?). > is to test > (static-if (assoc 'lexical-binding (buffer-local-variables)) > (provide 'lexical-binding)) > instead of doing `boundp' test. Sorry, but that makes no sense to me. Emacs support for `lexical-binding' is true (for Emacs 24+) regardless of whether that var is buffer-local variable (and with any value). > > Is this the thing to do? If not, what advice > > do you have for adapting a library to use > > lexical binding when available (Emacs 24+) but > > to also work when it's unavailable (Emacs < 24)? > > > [The doc just tells you how to convert code to > > use lexical binding. I see nothing about how > > to code compatibly for old and new Emacs.] >=20 > Well, I think it's fine to just keep that library as-is. > Even in the current lastest release there are still many > builtin packages are not converted to using lexical binding > at all. Just name a few I know, supercite, enriched-mode Certainly it's OK to keep such a library as is. I've been doing that for years. But I'm asking how to let it take advantage of lexical binding when that's available. That's the question I posed. I said how I intend to do that, but I asked if there's a better way.