From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Robin Tarsiger Newsgroups: gmane.emacs.devel Subject: cl-block less lexical than expected Date: Thu, 30 Dec 2021 12:12:52 -0600 Message-ID: <78900c46-4c9a-b690-95d3-a02f27be9e59@dasyatidae.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="17776"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.4.1 To: Emacs-Devel List Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Thu Dec 30 19:13:53 2021 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 1n2zw0-0004Tu-5a for ged-emacs-devel@m.gmane-mx.org; Thu, 30 Dec 2021 19:13:53 +0100 Original-Received: from localhost ([::1]:37284 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n2zvz-0004LA-0T for ged-emacs-devel@m.gmane-mx.org; Thu, 30 Dec 2021 13:13:51 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:42586) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n2zvA-0003Sp-OU for emacs-devel@gnu.org; Thu, 30 Dec 2021 13:13:00 -0500 Original-Received: from wout3-smtp.messagingengine.com ([64.147.123.19]:55267) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n2zv7-0002WK-TG for emacs-devel@gnu.org; Thu, 30 Dec 2021 13:13:00 -0500 Original-Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.west.internal (Postfix) with ESMTP id 0E3F43200D53 for ; Thu, 30 Dec 2021 13:12:54 -0500 (EST) Original-Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Thu, 30 Dec 2021 13:12:55 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dasyatidae.com; h=message-id:date:mime-version:to:from:subject:content-type :content-transfer-encoding; s=fm3; bh=Y0LDPu1t4sqHCj7LRnWoFb4RUn Ict5WhZmHzEQDzYFk=; b=CR6s8X1TL/5fnIVqQfQJJEW1YYa7pP+73jQiLsh3kj mI9270L50i8howF2BYKvwym2hrGVSkwaLpph2R/blrc0R4egKDe6OSo5FsiX07i/ NgmPULWZNpE1fO0dm7inyC4C48ZNpDlM715tYd8O4Xtyad6SVsVLQG/rV6ekVMS0 QqXc5FRJJVriVk81XZMigL27BaCStd87LVLVVceyxQ8yhr/xdTFLGb8IzYZGCKjp 0TOrrJ56be1JPwUBmYgXLnfSr2HPTUAouNYn7pl+Bjxy0ARbGJtFcRHiGv9p8Ol2 NvdSNAn0kuEa5L0nq03adtqzwdnU8IphxbM9Fuz/Fnfw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:message-id:mime-version:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=Y0LDPu 1t4sqHCj7LRnWoFb4RUnIct5WhZmHzEQDzYFk=; b=iM85ldq6nZcczCBsBxya6I NtFe6fS/kTcBjDZAgacYA4T9+kkbjSXpwaVxmmomelqT6BgDSHQCjHmdxLhJS5rx cZoF7OhKRANST3aJRdB/FIR0XTmDcWX24h9Y7YzWBBC56MJSpHlk4RngUBGLedNd wh5JhxiO1gxbfuon8mk+3UibqdA308TzCw1B2nlj2kSiUucJ4TeRutHaPoIqZaMw Qdtl+nedoaZmUJqyD9tE48Ei15HiR4TWoAcM27CkvwHzqt/gKwyb4p44XVB+XOny VFrQTQUqaxyK1v5mU2Q9aoGjharfjm4I6N5aOM5ttOQSsHe9DmJFHkELsrgjnGTw == X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvuddruddvfedgudduudcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefkffggfgfvhffutgfgsehtjeertddtfeejnecuhfhrohhmpeftohgsihhn ucfvrghrshhighgvrhcuoehrthhtsegurghshigrthhiuggrvgdrtghomheqnecuggftrf grthhtvghrnhepieehhfdtgfeijedvveffgedtffeileeiudffgefgheehgfegfeffheeg keegtdfgnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomh eprhhtthesuggrshihrghtihgurggvrdgtohhm X-ME-Proxy: Original-Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Thu, 30 Dec 2021 13:12:53 -0500 (EST) Content-Language: en-US-large Received-SPF: pass client-ip=64.147.123.19; envelope-from=rtt@dasyatidae.com; helo=wout3-smtp.messagingengine.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_PASS=-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:283673 Archived-At: Greetings. Today I was poking around with elisp and decided to look at the definitions of cl-block and cl-return-from. These are predictably described in the elisp manual as using lexical tags along the lines of how actual-CL block and return-from work. However, the way the macros are implemented doesn't line up with this; they do a static transformation on the tag name and then intern the result for use with catch/throw, and that yields dynamic semantics: (defun tmp/cl-block-test-1 () (cl-block foo (cl-return-from foo 'ok) 'not-reached)) (defun tmp/cl-block-test-2 () (cl-return-from foo 'bad)) (defun tmp/cl-block-test-3 () (cl-block foo (tmp/cl-block-test-2) ;; Necessary to avoid the catch being discarded. (cl-return-from foo 'correct))) (tmp/cl-block-test-1) ==> ok ; This is fine. (tmp/cl-block-test-2) ==> ; Also okay. (tmp/cl-block-test-3) ==> bad ; But the foo block isn't actually lexical! I have to think that since catch and throw both take evaluated expressions for their tags, a more suitable implementation might do a static transformation to choose an out-of-the-way lexical _variable_ name which would then be let-bound to a gensym during the body. cl-return-from could then try to evaluate the variable to get the tag; the warnings/errors for bad tags would be awkward to read, but at least the semantics would be correct. An unbound tag variable would also be warned about during byte-compilation. Thoughts? -RTT