unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Scott Bell <sctb@me.com>
To: Heime <heimeborgia@protonmail.com>
Cc: help-gnu-emacs@gnu.org
Subject: Re: pcase with progn
Date: Wed, 27 Nov 2024 15:33:10 -0700	[thread overview]
Message-ID: <m2a5dk71eh.fsf@me.com> (raw)
In-Reply-To: <IrPUop5ELSG1rPxYCM3H8g39y4PF5cdyeJJMT1WlKJ52_YZLzN6V-rOvAl9UQldVYk55mQm2CG8sZc-8hoK2tZeczy4PJmV8oudLaHybCdg=@protonmail.com> (Heime's message of "Wed, 27 Nov 2024 20:50:58 +0000")

Heime <heimeborgia@protonmail.com> writes:

> (defun pola-symbol-name (sbl &optional sel)
>   "Get the string representation of symbol SBL.  If it is
> already a string, return it unchanged."
>   ...
> The command should return the string representation of symbol if
> it exists.  When the command fails (symbol does not exist), are commands
> customarily return nil or an error? 

This depends entirely on the meaning of your function and its intended
usage. Generally speaking, it’s preferable to return nil to represent
failure unless nil is a valid value in the successful case. Since your
function always returns a string if it’s successful, it would probably
be good to return nil on failure.

Errors are most often employed when the program has encountered some
value or condition under which it’s not possible to proceed normally. In
that case, signalling an error stops execution and returns to the
nearest enclosing error handler which will decide what to do about it.



  reply	other threads:[~2024-11-27 22:33 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-27 18:45 pcase with progn Heime via Users list for the GNU Emacs text editor
2024-11-27 19:39 ` Scott Bell
2024-11-27 20:50   ` Heime via Users list for the GNU Emacs text editor
2024-11-27 22:33     ` Scott Bell [this message]
2024-11-28 14:44 ` Stefan Monnier 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=m2a5dk71eh.fsf@me.com \
    --to=sctb@me.com \
    --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).