From: Tassilo Horn <tsdh@gnu.org>
To: Heime via Users list for the GNU Emacs text editor
<help-gnu-emacs@gnu.org>
Cc: Heime <heimeborgia@protonmail.com>
Subject: Re: Symbols or strings as arguments
Date: Thu, 28 Nov 2024 06:36:10 +0100 [thread overview]
Message-ID: <87cyifq5rp.fsf@gnu.org> (raw)
In-Reply-To: <YEUNvLtyjxQzEix73_I97QnGXV66wvL6w9QAQSgI-v30t37TmP2QtOlTpR3SLNh1dvdejbEpJegmCMmpZ-KpwoPpvLUWaPyGrhjJ9plySu0=@protonmail.com> (Heime via Users list for the's message of "Wed, 27 Nov 2024 15:05:18 +0000")
Heime via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org> writes:
> I wonder whether developers would preferentially use symbols rather
> than strings in arguments.
>
> Consider calling (cupola '(72 tabtrail local)) versus (cupola '(72
> "tabtrail" "local"))
Obviously, it depends. If the arguments are essentially an enumeration,
i.e., the possible/allowed values are just a small set, then I'd use
symbols or keywords. E.g., an argument location with possible values
local and remote => :local / :remote. An argument first-name, well,
that's a string because it can be anything.
It also depends on the usage of the argument. If you just print it out,
a string is fine. If you dispatch on it (using case, pcase, cond),
keywords and symbols are probably better. Mostly because they stand out
a bit and it's immediately visible that they have special meaning
affecting the control flow.
Bye,
Tassilo
next prev parent reply other threads:[~2024-11-28 5:36 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-27 15:05 Symbols or strings as arguments Heime via Users list for the GNU Emacs text editor
2024-11-28 5:36 ` Tassilo Horn [this message]
2024-11-28 11:59 ` Heime 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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87cyifq5rp.fsf@gnu.org \
--to=tsdh@gnu.org \
--cc=heimeborgia@protonmail.com \
--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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).