From: Jean Louis <bugs@gnu.support>
To: help-gnu-emacs@gnu.org
Subject: Re: operations on path lists
Date: Tue, 7 Feb 2023 11:33:08 +0300 [thread overview]
Message-ID: <Y+IMxOFwtSVspNtC@protected.localdomain> (raw)
In-Reply-To: <87sffljeg5.fsf@dataswamp.org>
* Emanuel Berg <incal@dataswamp.org> [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/
next prev parent reply other threads:[~2023-02-07 8:33 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-04 5:32 operations on path lists Samuel Wales
2023-02-04 6:32 ` Jean Louis
2023-02-04 8:06 ` Emanuel Berg
2023-02-04 17:21 ` [External] : " Drew Adams
2023-02-04 18:32 ` Jean Louis
2023-02-04 21:51 ` Emanuel Berg
2023-02-07 8:34 ` Jean Louis
2023-02-07 10:26 ` Emanuel Berg
2023-02-07 22:39 ` Jean Louis
2023-02-08 2:48 ` Drew Adams
2023-02-08 18:46 ` Drew Adams
2023-02-08 20:09 ` Jean Louis
2023-02-04 18:28 ` Jean Louis
2023-02-04 21:41 ` Emanuel Berg
2023-02-07 8:33 ` Jean Louis [this message]
2023-02-07 10:30 ` Emanuel Berg
2023-02-07 14:55 ` [External] : " Drew Adams
2023-02-07 14:55 ` Drew Adams
2023-02-04 21:44 ` Samuel Wales
2023-02-04 21:49 ` Samuel Wales
2023-02-04 14:59 ` Emanuel Berg
2023-02-07 7:35 ` Jean Louis
2023-02-07 10:27 ` Emanuel Berg
2023-02-11 8:18 ` James Thomas
2023-02-11 14:02 ` Ruijie Yu via Users list for the GNU Emacs text editor
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Y+IMxOFwtSVspNtC@protected.localdomain \
--to=bugs@gnu.support \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.