From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Jean Louis Newsgroups: gmane.emacs.help Subject: Re: operations on path lists Date: Tue, 7 Feb 2023 11:33:08 +0300 Message-ID: References: <87y1pdkg6p.fsf@dataswamp.org> <87sffljeg5.fsf@dataswamp.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="6412"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mutt/2.2.9+54 (af2080d) (2022-11-21) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Tue Feb 07 10:48:39 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 1pPKac-0001Mc-D4 for geh-help-gnu-emacs@m.gmane-mx.org; Tue, 07 Feb 2023 10:48:38 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pPKa3-0003Bs-Ny; Tue, 07 Feb 2023 04:48:03 -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 1pPKa0-0003BG-97 for help-gnu-emacs@gnu.org; Tue, 07 Feb 2023 04:48:00 -0500 Original-Received: from stw1.rcdrun.com ([217.170.207.13]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pPKZy-0007SE-Ag for help-gnu-emacs@gnu.org; Tue, 07 Feb 2023 04:47:59 -0500 Original-Received: from localhost ([::ffff:102.87.18.138]) (AUTH: PLAIN admin, TLS: TLS1.3,256bits,ECDHE_RSA_AES_256_GCM_SHA384) by stw1.rcdrun.com with ESMTPSA id 0000000000103A92.0000000063E21E30.000054F5; Tue, 07 Feb 2023 02:47:28 -0700 Mail-Followup-To: help-gnu-emacs@gnu.org Content-Disposition: inline In-Reply-To: <87sffljeg5.fsf@dataswamp.org> Received-SPF: pass client-ip=217.170.207.13; envelope-from=bugs@gnu.support; helo=stw1.rcdrun.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, 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:142628 Archived-At: * Emanuel Berg [2023-02-05 16:15]: > Jean Louis wrote: > > >>> (cond ((file-directory-p file) (expand-file-name file)) > >>> (t nil)) > >> > >> (when (file-directory-p file) > >> (expand-file-name file) ) > > > > I am aware of it, I prefer using `cond' as I get > > more clarity. > > The (t nil) part is of no use, even if you stick to `cond'. > > "If no clause succeeds, cond returns nil." > > And: one COND, one branch or BODY - in idiomatic Lisp, that's > `when'. I use it to see the `nil'. To help person how you think is better, then write it in your way for that person. `cond' in my world has special place, it is not really replacement for `if' or other conditionals. It is used in period of programming as it helps with thinking during the function ripening. In general I will first want to define what the function should return without other conditions. The ripening process begins. (defun my-function (arg) (cond (t (user-error "Verify me")))) Then I start adding conditions: (defun my-function (arg) (cond ((zerop arg) (message "Worked")) (t nil))) And more to it: (defun my-function (arg) (cond ((stringp arg) (message "I got `%s'" arg)) ((zerop arg) (message "Worked")) (t nil))) and then I add more: (defun my-function (arg) (cond ((numberp arg) (message "I got number `%s'" arg)) ((stringp arg) (message "I got string `%s'" arg)) ((zerop arg) (message "Worked")) (t nil))) I hope you can see how conditions are developed during time. In the process of ripening it is good to see `nil' visually in the last condition from beginning. The return can be `nil' but also something else. Once function is "stable", then I may remove what is not any more necessary for some readers. Got that one? -- Jean Take action in Free Software Foundation campaigns: https://www.fsf.org/campaigns In support of Richard M. Stallman https://stallmansupport.org/