help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Symbols or strings as arguments


From: Heime
Subject: Re: Symbols or strings as arguments
Date: Thu, 28 Nov 2024 11:59:20 +0000





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.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]