emacs-devel
[Top][All Lists]
Advanced

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

Re: Distinguishing `consp` and `functionp`


From: Stefan Monnier
Subject: Re: Distinguishing `consp` and `functionp`
Date: Fri, 26 Jan 2024 16:13:14 -0500
User-agent: Gnus/5.13 (Gnus v5.13)

> Is fine and correct, but:
>
> (funcall '(lambda ()))
>
> Shouldn't be fine, yet it is.

That is related but I'm not really interested in disallowing it.

Rather I'm annoyed at the corner cases where

    (functionp (mapcar ...))

can occasionally return t, simply because the returned list happens to
start with the symbol `closure` or `lambda`.

This is one of the motivations why completion tables are defined to
allow "lists of strings" or "alists whose keys can be strings or
symbols" but not "lists of symbols": even though in practice lists of
symbols work fine 99.9% of the time, they are not reliable because
they'd be confused with a function when the first symbol happens to be
`lambda` or `closure`.

There are various other circumstances where we like to accept either
a function or a list of things, but where the test is not reliable and
can give different results depending on whether the code is compiled.


        Stefan




reply via email to

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