unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* coding standard for allowed arguments of predicates
@ 2020-12-18 14:49 Roland Winkler
  2020-12-18 15:00 ` Philipp Stephani
  0 siblings, 1 reply; 3+ messages in thread
From: Roland Winkler @ 2020-12-18 14:49 UTC (permalink / raw)
  To: emacs-devel

Is there a coding standard for allowed arguments of predicates?
I have always assumed that predicates should accept any type of
argument;  but I cannot find this documented anywhere.

The context of my question is `iso8601-valid-p'.  It assumes that
its argument must be a string.  Is this a bug?  In my usage example,
the argument of `iso8601-valid-p' could also be nil.

If, indeed, predicates should always accept any type of argument,
I suggest to document this in the elisp manual.



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

* Re: coding standard for allowed arguments of predicates
  2020-12-18 14:49 coding standard for allowed arguments of predicates Roland Winkler
@ 2020-12-18 15:00 ` Philipp Stephani
  2020-12-18 21:59   ` Roland Winkler
  0 siblings, 1 reply; 3+ messages in thread
From: Philipp Stephani @ 2020-12-18 15:00 UTC (permalink / raw)
  To: Roland Winkler; +Cc: Emacs developers

Am Fr., 18. Dez. 2020 um 15:49 Uhr schrieb Roland Winkler <winkler@gnu.org>:
>
> Is there a coding standard for allowed arguments of predicates?
> I have always assumed that predicates should accept any type of
> argument;  but I cannot find this documented anywhere.
>
> The context of my question is `iso8601-valid-p'.  It assumes that
> its argument must be a string.  Is this a bug?  In my usage example,
> the argument of `iso8601-valid-p' could also be nil.
>
> If, indeed, predicates should always accept any type of argument,
> I suggest to document this in the elisp manual.
>

There are lots of predicates that accept only certain types, e.g.
(file-readable-p 123) also signals an error. Typically only the
predicates that check for types (stringp, integerp, listp, etc.)
accept any type.



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

* Re: coding standard for allowed arguments of predicates
  2020-12-18 15:00 ` Philipp Stephani
@ 2020-12-18 21:59   ` Roland Winkler
  0 siblings, 0 replies; 3+ messages in thread
From: Roland Winkler @ 2020-12-18 21:59 UTC (permalink / raw)
  To: Philipp Stephani; +Cc: Emacs developers

On Fri Dec 18 2020 Philipp Stephani wrote:
> Am Fr., 18. Dez. 2020 um 15:49 Uhr schrieb Roland Winkler <winkler@gnu.org>:
> > The context of my question is `iso8601-valid-p'.  It assumes that
> > its argument must be a string.  Is this a bug?  In my usage example,
> > the argument of `iso8601-valid-p' could also be nil.
> 
> There are lots of predicates that accept only certain types, e.g.
> (file-readable-p 123) also signals an error. Typically only the
> predicates that check for types (stringp, integerp, listp, etc.)
> accept any type.

Thanks; thinking about this once more it makes sense that not all
predicates need to check the type of their arguments.  In the
example of `iso8601-valid-p' one could argue that it is at the
borderline of the class of predicates that check for (in this case:
very particular) types.  But a caller of this predicate can handle
the possibility of non-string arguments, too.



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

end of thread, other threads:[~2020-12-18 21:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-12-18 14:49 coding standard for allowed arguments of predicates Roland Winkler
2020-12-18 15:00 ` Philipp Stephani
2020-12-18 21:59   ` Roland Winkler

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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