all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Symbols or strings as arguments
@ 2024-11-27 15:05 Heime via Users list for the GNU Emacs text editor
  2024-11-28  5:36 ` Tassilo Horn
  0 siblings, 1 reply; 3+ messages in thread
From: Heime via Users list for the GNU Emacs text editor @ 2024-11-27 15:05 UTC (permalink / raw)
  To: Heime via Users list for the GNU Emacs text editor


I wonder whether developers would preferentially use symbols rather than 
strings in arguments.  

Consider calling (cupola '(72 tabtrail local)) versus (cupola '(72 "tabtrail" "local"))







^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Symbols or strings as arguments
  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
  2024-11-28 11:59   ` Heime via Users list for the GNU Emacs text editor
  0 siblings, 1 reply; 3+ messages in thread
From: Tassilo Horn @ 2024-11-28  5:36 UTC (permalink / raw)
  To: Heime via Users list for the GNU Emacs text editor; +Cc: Heime

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



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Symbols or strings as arguments
  2024-11-28  5:36 ` Tassilo Horn
@ 2024-11-28 11:59   ` Heime via Users list for the GNU Emacs text editor
  0 siblings, 0 replies; 3+ messages in thread
From: Heime via Users list for the GNU Emacs text editor @ 2024-11-28 11:59 UTC (permalink / raw)
  To: Tassilo Horn; +Cc: Heime via Users list for the GNU Emacs text editor






Sent with Proton Mail secure email.

On Thursday, November 28th, 2024 at 5:36 PM, Tassilo Horn <tsdh@gnu.org> wrote:

> 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. --- Tassilo

Focusing on arguments for dispatching commands on them using case, pcase, 
cond, I shall use keywords and symbols to be immediately visible their 
special meaning.



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-11-28 11:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2024-11-28 11:59   ` Heime via Users list for the GNU Emacs text editor

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.