[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: pcase with progn
From: |
Scott Bell |
Subject: |
Re: pcase with progn |
Date: |
Wed, 27 Nov 2024 15:33:10 -0700 |
User-agent: |
Gnus/5.13 (Gnus v5.13) |
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.