From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Phil Sainty Newsgroups: gmane.emacs.bugs Subject: bug#49116: 28.0.50; Why `bound-and-true-p' is not working in lexical binding? Date: Sun, 20 Jun 2021 00:49:14 +1200 Message-ID: <3157c274e97fc9db7ceb345ba020f74b@webmail.orcon.net.nz> References: <861r8yozg5.fsf@protected.rcdrun.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="4754"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Orcon Webmail Cc: 49116-done@debbugs.gnu.org To: Jean Louis Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Jun 19 14:50:11 2021 Return-path: Envelope-to: geb-bug-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 1luaQN-00015d-91 for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 19 Jun 2021 14:50:11 +0200 Original-Received: from localhost ([::1]:50446 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1luaQL-0001iE-Cf for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 19 Jun 2021 08:50:09 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:35798) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1luaQE-0001gx-QR for bug-gnu-emacs@gnu.org; Sat, 19 Jun 2021 08:50:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:47182) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1luaQE-0007pK-JL for bug-gnu-emacs@gnu.org; Sat, 19 Jun 2021 08:50:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1luaQE-0001Ql-GV for bug-gnu-emacs@gnu.org; Sat, 19 Jun 2021 08:50:02 -0400 Resent-From: Phil Sainty Original-Sender: "Debbugs-submit" Resent-To: bug-gnu-emacs@gnu.org Resent-Date: Sat, 19 Jun 2021 12:50:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: cc-closed 49116 X-GNU-PR-Package: emacs Mail-Followup-To: 49116@debbugs.gnu.org, psainty@orcon.net.nz, bugs@gnu.support Original-Received: via spool by 49116-done@debbugs.gnu.org id=D49116.16241069615441 (code D ref 49116); Sat, 19 Jun 2021 12:50:02 +0000 Original-Received: (at 49116-done) by debbugs.gnu.org; 19 Jun 2021 12:49:21 +0000 Original-Received: from localhost ([127.0.0.1]:58726 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1luaPY-0001Ph-Um for submit@debbugs.gnu.org; Sat, 19 Jun 2021 08:49:21 -0400 Original-Received: from smtp-4.orcon.net.nz ([60.234.4.59]:32829) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1luaPU-0001PX-Tz for 49116-done@debbugs.gnu.org; Sat, 19 Jun 2021 08:49:19 -0400 Original-Received: from [10.253.37.70] (port=48660 helo=webmail.orcon.net.nz) by smtp-4.orcon.net.nz with esmtpa (Exim 4.90_1) (envelope-from ) id 1luaPS-0006F3-Vq; Sun, 20 Jun 2021 00:49:15 +1200 Original-Received: from ip-116-251-162-85.kinect.net.nz ([116.251.162.85]) via [10.253.37.253] by webmail.orcon.net.nz with HTTP (HTTP/1.1 POST); Sun, 20 Jun 2021 00:49:14 +1200 In-Reply-To: <861r8yozg5.fsf@protected.rcdrun.com> X-Sender: psainty@orcon.net.nz X-GeoIP: -- X-Spam_score: -2.9 X-Spam_score_int: -28 X-Spam_bar: -- X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:208723 Archived-At: On 2021-06-19 23:39, Jean Louis wrote: > When I evaluate following it is not detecting variable `direction' > under lexical bindings: > > (defun verify-direction (timestamp &optional direction) > (cond ((bound-and-true-p direction) (message "OK")))) > > (verify-direction "10:00" t) ⇒ nil > > I would like to understand if it is intended to be so? > > Or is this possible bug? This is expected / not a bug (and so I'm closing it). (bound-and-true-p VAR) is syntactic sugar for (and (boundp 'VAR) VAR) which means that it works only for dynamic variables (i.e. variables stored in the value slot of a symbol). Under lexical binding, function arguments are lexical variables, which means they are not stored in the symbol of that name, and hence cannot be detected with `boundp'. In your case there's no need to be checking whether `direction' is "bound" -- whether it's lexical or dynamic, you already *know* that it exists because it's an argument for the function in which you're checking it. All you want is the "true-p" part, which is implicit in every value (either nil or non-nil). Instead of "(bound-and-true-p direction)" just use "direction". -Phil