From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: uzibalqa Newsgroups: gmane.emacs.help Subject: Re: Passing optional arguments for use with internal functions Date: Sun, 30 Jul 2023 16:09:14 +0000 Message-ID: References: <0Ezo2Srah2_DE-D1XG3MBYVEmAvnfHLu8cKpS3oJa4Hn5ADeV7sBbHFTtIzRAFv461O5XlpcjkyImCJHO7DKvaM492vQW7cz9wXL_VaDAdQ=@proton.me> <87tttoux4p.fsf@dataswamp.org> <87o7jwufju.fsf@dataswamp.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="13189"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 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 Sun Jul 30 19:01:34 2023 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 1qQ9nR-0003Ec-40 for geh-help-gnu-emacs@m.gmane-mx.org; Sun, 30 Jul 2023 19:01:33 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qQ8z8-0004Le-0s; Sun, 30 Jul 2023 12:09:34 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qQ8z5-0004LP-LK for help-gnu-emacs@gnu.org; Sun, 30 Jul 2023 12:09:31 -0400 Original-Received: from mail-40138.protonmail.ch ([185.70.40.138]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qQ8z0-0003xu-Px for help-gnu-emacs@gnu.org; Sun, 30 Jul 2023 12:09:31 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=proton.me; s=protonmail; t=1690733362; x=1690992562; bh=VkI6Lof4UyxgSoq15OktbElUDfw3UthD+Af4Ao6nMBc=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=St7DrkAdTTkVpufguiePWJQZ/Pk32R04OnBTguy1vJPqdOLtOqd3LGd1df/PflwSr xSdrM1M7BDI0Z4GsSgGMZEGIqXFS/8pGOkiis6KjSV6Cw2yGwyhM0ddqA2gxHLOp21 HDoeQXyxCuM1H80wATUlLcPfOCeMYr9pt2lXWrnj4yxv/DS2Lqu4dmakka16mXOCmU 7NHUEafvOMtfqq4+RDJBvIjBMa4iUSaHdiFH7/uLDPq2SvjnR1u5bcIwmC+BZC4a5M Peg8X3LeGurd4lFGHlQZtpzyX2M1jH4i4MGNnyPTtWwbpmilJzZsfyJDb1/weg9o/W pUbqfyqkBkT5A== In-Reply-To: <87o7jwufju.fsf@dataswamp.org> Feedback-ID: 52887082:user:proton Received-SPF: pass client-ip=185.70.40.138; envelope-from=uzibalqa@proton.me; helo=mail-40138.protonmail.ch X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 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_MSPIKE_H5=-1, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.29 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-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.help:144499 Archived-At: ------- Original Message ------- On Saturday, July 29th, 2023 at 5:11 AM, Emanuel Berg = wrote: > Heime wrote: >=20 > > > Optional arguments defaults to nil, if that is an > > > acceptable value you can use it as you do, if not you can > > > check if it is nil first thing in the function and if it > > > is, set it to something that works, e.g. > > >=20 > > > (or arg (setq arg 0)) > >=20 > > Does the condition you specified work whether the binding is > > lexical or dynamic ? >=20 >=20 > If there is an optional argument with that name yes, since > formal parameters (function arguments) are always lexical. Yes, I am discussing (or arg (setq arg 0)) in the context of an optional argument by that name, for the purpose of setting a default if it was not specified.=20 =20 > ;;; -- lexical-binding: nil -- >=20 > (defvar arg) > (setq arg 2) >=20 > (defun echo-arg (&optional arg) > (or arg (setq arg 1)) > (message "%s" arg) ) >=20 > ;; (echo-arg) >=20 > This will still echo 1. Now that there has been a change from dynamic to lexical binding, this becomes a problem. What command should one use to set a default value to an optional argument for the current lexical binding files ?=20 =20 > -- > underground experts united > https://dataswamp.org/~incal