From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Heime via Users list for the GNU Emacs text editor Newsgroups: gmane.emacs.help Subject: Re: Passing a list of symbols to function argument Date: Fri, 29 Nov 2024 21:41:27 +0000 Message-ID: References: <87ser97r3k.fsf@gmx.net> <87ldx17oxv.fsf@gmx.net> <87h67p7mpu.fsf@gmx.net> Reply-To: Heime 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="2480"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Heime via Users list for the GNU Emacs text editor To: Stephen Berman Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Fri Nov 29 22:42:13 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 1tH8kf-0000S4-4A for geh-help-gnu-emacs@m.gmane-mx.org; Fri, 29 Nov 2024 22:42:13 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tH8k6-00007k-MP; Fri, 29 Nov 2024 16:41:38 -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 1tH8k4-00007a-PZ for help-gnu-emacs@gnu.org; Fri, 29 Nov 2024 16:41:37 -0500 Original-Received: from mail-106104.protonmail.ch ([79.135.106.104]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tH8k2-0004Td-Rv for help-gnu-emacs@gnu.org; Fri, 29 Nov 2024 16:41:36 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail3; t=1732916491; x=1733175691; bh=rzGrY0cdqnoBg0bPV/n2TfkB+HYM4dCGEqLzp9dq2So=; 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:List-Unsubscribe:List-Unsubscribe-Post; b=JG5utKhYeuMUYx3U5fAadvifz2XIRa8BW2AfA3JVLkzHp7rnAIKkb/GlY5aomakuo CIIGUvwz2IT+HU8dWDWOF07PTiuzzbrlLIvenvTbzR1A/zaWmQSBJmjFQHs2kkWpzf cMqk7OT8yYQdBksbZYaS7C0tk1DO1GU4LixoxnXzpgU3IMFdLxxv7fMX6rfQjplyCo uMUruFUGR8759kwR86k7KxnmJVoRbjX4p5T3WVDMz1lDNHuVSnLh9RdOo75oGxq6a/ JNK4Hz++epkmd4DatItTnqGZqrMSIZeP+36Eq6Eq6G8vGHNv7vtozyZFhPZP+G3DYu yyjoQZ5b2hHLw== In-Reply-To: <87h67p7mpu.fsf@gmx.net> Feedback-ID: 57735886:user:proton X-Pm-Message-ID: 56e27ec618217ab55e0b058e4b482058478ba92f Received-SPF: pass client-ip=79.135.106.104; envelope-from=heimeborgia@protonmail.com; helo=mail-106104.protonmail.ch X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.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, FREEMAIL_FROM=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-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:148451 Archived-At: On Saturday, November 30th, 2024 at 9:29 AM, Stephen Berman wrote: > > > > I want the function to accept both symbols and strings. intern must= then > > > > be applied only when a string is passed. Which undoubtedly needs a = conditional > > > > check. > > > >=20 > > > > Perhaps I should also test whether the argument is a symbol or do t= he if > > > > and pcase handle errors (because the commands will be skipped). > > > >=20 > > > > (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)))) > > >=20 > > > This seems fine; `if' does not do error handling, nor does` pcase' AF= AIK > > > (but there are several variants and extensions of pcase, and I'm not = too > > > familiar with them, so maybe some of them do error handling), but > > > `condition-case' is the basic error handling form in Elisp. Alternati= vely, since the error only happens in noninteractive calls (since interacti= ve calls use` completing-read', which returns strings), > > > you could condition on `called-interactively-p'. > > >=20 > > > Steve Berman > >=20 > > For the interactive call I want to pass the three values so that > > actm-seqr will be a list of three objects. > >=20 > > Thus I do > >=20 > > (list (list colw rsel scope)) > >=20 > > Would the above be correct? >=20 >=20 > Yes. >=20 > > With only (list colw rsel scope) emacs does complain. >=20 >=20 > Because that means the interactive call passes three arguments, but your > definition of `poalatuk' only specifies one argument parameter. >=20 > > I wonder whether actm-seqr will give me ((72 tabtrail global)) > > and not (72 tabtrail global). >=20 > 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=20 (72 tabtrail global) ; list of three entries to actm-seqr? =20 > > Have also been looking at the possibility of using > >=20 > > (list (list colw (intern rsel) (intern scope))) > >=20 > > Or would this be considered replication? Because the call > > to intern would happen later anyway. >=20 > 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 gets called when calling the function programatically with strings.