From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stephen Berman Newsgroups: gmane.emacs.help Subject: Re: Passing a list of symbols to function argument Date: Fri, 29 Nov 2024 22:52:25 +0100 Message-ID: <87cyid7lnq.fsf@gmx.net> References: <87ser97r3k.fsf@gmx.net> <87ldx17oxv.fsf@gmx.net> <87h67p7mpu.fsf@gmx.net> Mime-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="40362"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Heime via Users list for the GNU Emacs text editor To: Heime Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Fri Nov 29 22:53:01 2024 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 1tH8v6-000ALX-9G for geh-help-gnu-emacs@m.gmane-mx.org; Fri, 29 Nov 2024 22:53:00 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tH8uf-0001D6-1f; Fri, 29 Nov 2024 16:52:33 -0500 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 1tH8ud-0001Cw-V7 for help-gnu-emacs@gnu.org; Fri, 29 Nov 2024 16:52:31 -0500 Original-Received: from mout.gmx.net ([212.227.15.19]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tH8ub-0000p3-PB for help-gnu-emacs@gnu.org; Fri, 29 Nov 2024 16:52:31 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.net; s=s31663417; t=1732917146; x=1733521946; i=stephen.berman@gmx.net; bh=WSB/JXCXFavsueD+BG81N21nv36r06a58jdBwufWhEo=; h=X-UI-Sender-Class:From:To:Cc:Subject:In-Reply-To:References:Date: Message-ID:MIME-Version:Content-Type:Content-Transfer-Encoding:cc: content-transfer-encoding:content-type:date:from:message-id: mime-version:reply-to:subject:to; b=fPp4GKDtyNhkN5X/lyJlShEGz7VzG9qdiXwT5kIS3lDYb82pg1d/zPpa3Y1U9m6c YELJmG+FdpskHEiau5EL+yV3aAkAkWu6e7r2PvPeSXoXt7guMjR9wITgW+pHbA4f3 boP2u2q++O1+K6/bbJRQLC2z2EPzWt9Vrg6YXTi3xGnJ7xzPOE8hlev6zTU3DRD7P 6yEv/Q7Ky4RjLAPtOzJBkuCWbJB0qM7cMOUAwTGPcvTTqflSGmWD0y7kVsgWKu4Lh DJpGQyO2FP4IMBDq3+GZ1E3WNVO1Ls4IzKAUA/h7WseOsrj8kvCHN7TzFe61qz1WQ skPlFVKWhfD3Xztszg== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Original-Received: from strobelfssd ([88.130.49.222]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1M5QJD-1tIVp90FNt-0094nf; Fri, 29 Nov 2024 22:52:26 +0100 In-Reply-To: (Heime's message of "Fri, 29 Nov 2024 21:41:27 +0000") X-Provags-ID: V03:K1:iGjwgpaqxZRMtihRrea6+uSt1FPW1wHPHIndNwadhTy54FtXBlF KaRk/RcdGcLwR5SQgeaxbgtCHBxJXEdoJxDKZwfP441+IW9ZOEVYApZo8ACUQ6tUDEfXUx8 0pPZ5Yd3K0OMMSZCk+cBpPtPIj5eJrX5j2ML2Nsr3GP13MrOTcRIe7LFSaZZxtEXgZDuxDa bzyfLxp5b6l4Y06yMcyyQ== UI-OutboundReport: notjunk:1;M01:P0:vsPiIoJS8qo=;dF9XsoQg1qvQJ8HiZxurS9G8t9a rOvcx91Y/kMB0jUBYucusri6nsYoqXlwj2nmwD5giCAtyOXfQP9oVFQypL5jDiSQG3C7KVJ6q cKOeaQRxHgCuff5kuhAk3dMuE3QZhBH7ZuIWz0Ikg0OZ2Rca2dgREel9T4PmvJwuDfVtSdjsO T2NmPAVO8PNbpK7I9kXCTDakBrzwaVIoUn8r5I46cKsGwUGCCLsr7VPUoGHJjwPwDHTyWx8PU XnG52o5vgSM/6l6Y9+mBOo51VW6iqbSNslik/EdxTZvN/e4IZxCdyIGX3Yc+wdat5Gv7RI/ka E0VF3TAUpsM1uU/47GfDVEa/t6AD87z/Z+/W2u6AbuRbwdr/MYv8ZymcWCVxuVI5zFKlZ23Md /eEfnvI5P/OZPJB3xTmV1GAzweh6zeH++d1ny6F0a7909IHK0UnVU2JMs/tLp4h2TjEsMg10p pbXDHcjl7PQCh93hcHKj+lFIs6rDPQOz0x9gm7Dukc6oK8Jihqsf4D4N+MA1WpKEJqONVPhBh g3doinAIOn5iDgfb8Cbf6Yr5MzUpFj/mdhGo2aA+qfNX8IHts9UjUYFvpAyjIBNY44W0eBJ+p /J8lYqjVNlpe6DGC80FUNjFMwCbF+ar4AufRpVzP8+IdYoHQRQnipMSbwFXMLTclsEZpse2wB 8F5JHSYN7fw1YfG0i4KbGP7P0AP3uIBG9YcvBjTEdGPibGP8xikplUegM4dPzFv6lwYFvtYc8 KKj6aobDcSl+7gDFxAFHN9vDdyeUbzBoYsk0XhS1kmFgKe/tLWlqj9Nm/e0QpytXW7OD9NKV Received-SPF: pass client-ip=212.227.15.19; envelope-from=stephen.berman@gmx.net; helo=mout.gmx.net X-Spam_score_int: -36 X-Spam_score: -3.7 X-Spam_bar: --- X-Spam_report: (-3.7 / 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.93, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=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.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:148452 Archived-At: On Fri, 29 Nov 2024 21:41:27 +0000 Heime wrot= e: > On Saturday, November 30th, 2024 at 9:29 AM, Stephen Berman > wrote: > >> > > > I want the function to accept both symbols and strings. intern mu= st then >> > > > be applied only when a string is passed. Which undoubtedly needs = a >> > > > conditional >> > > > check. >> > > > >> > > > Perhaps I should also test whether the argument is a symbol or do= the if >> > > > and pcase handle errors (because the commands will be skipped). >> > > > >> > > > (let* ((colw (nth 0 actm-seqr)) >> > > > (rsel (if (stringp (nth 1 actm-seqr)) >> > > > (intern (nth 1 actm-seqr)) >> > > > (nth 1 actm-seqr))) >> > > > (scope (if (stringp (nth 2 actm-seqr)) >> > > > (intern (nth 2 actm-seqr)) >> > > > (nth 2 actm-seqr)))) >> > > >> > > This seems fine; `if' does not do error handling, nor does` pcase' = AFAIK >> > > (but there are several variants and extensions of pcase, and I'm no= t too >> > > familiar with them, so maybe some of them do error handling), but >> > > `condition-case' is the basic error handling form in >> > > Elisp. Alternatively, since the error only happens in noninteractiv= e >> > > calls (since interactive calls use` completing-read', which returns >> > > strings), >> > > you could condition on `called-interactively-p'. >> > > >> > > Steve Berman >> > >> > For the interactive call I want to pass the three values so that >> > actm-seqr will be a list of three objects. >> > >> > Thus I do >> > >> > (list (list colw rsel scope)) >> > >> > Would the above be correct? >> >> >> Yes. >> >> > With only (list colw rsel scope) emacs does complain. >> >> >> Because that means the interactive call passes three arguments, but you= r >> definition of `poalatuk' only specifies one argument parameter. >> >> > I wonder whether actm-seqr will give me ((72 tabtrail global)) >> > and not (72 tabtrail global). >> >> I don't know what you mean; actm-seqr is the function parameter, a >> variable whose value is whatever is passed on calling the function >> either interactively or noninteractively. > > For the interactive part, would returning > > (list (list colw (intern rsel) (intern scope))) > > pass > > ((72 tabtrail global)) ; list with single element being a list > > or > > (72 tabtrail global) ; list of three entries > > to actm-seqr? The answer is in message displayed when you do `M-x poalatuk' and act appropriately on the prompts, isn't it? >> > Have also been looking at the possibility of using >> > >> > (list (list colw (intern rsel) (intern scope))) >> > >> > Or would this be considered replication? Because the call >> > to intern would happen later anyway. >> >> Then it would cause the error you reported in your OP. > > (list (list colw (intern rsel) (intern scope))) > > The above will be for the interactive part, so that the string values > would be changed immediately to symbols. > > And since I now fixed the problem by checking with stringp so intern get= s > called when calling the function programatically with strings. Ok. Steve Berman