unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: "João Távora" <joaotavora@gmail.com>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: emacs-devel@gnu.org
Subject: Re: Distinguishing `consp` and `functionp`
Date: Tue, 30 Jan 2024 08:58:39 +0000	[thread overview]
Message-ID: <CALDnm50QnCyeNwywqUOAn8GH6bsdrSqFXBaaJDDFSp6CxgxxyQ@mail.gmail.com> (raw)
In-Reply-To: <jwvil3bq5ff.fsf-monnier+emacs@gnu.org>

On Mon, Jan 29, 2024 at 8:00 PM Stefan Monnier <monnier@iro.umontreal.ca> wrote:

> The patch I sent doesn't change `functionp`, but indeed makes way for
> such a change (and changing `functionp` is the driving force behind it).

I've now briefly checked Common Lisp land.  Allegro CL is the
only one approaching Elisp's level of salad.  But at least functionp
does what you want it to do.

CL-USER> (funcall (list 'lambda nil 42))
42 (6 bits, #x2a, #o52, #b101010)
CL-USER> (functionp (list 'lambda nil 42))
NIL

But then there's the common pattern in libraries:

  (let ((value (if (functionp user-visible-variable)
                   (funcall user-visible-variable)
                 user-visible-variable)))
    ...)

Won't this break a user's config containing:

  (setq user-visible-variable '(lambda () 42))

?

> > Alright.  I wouldn't be surprised if I wasn't passing lists as lambdas
> > around in that extension.  I used to do that, and saw many fall prety
> > to this, when their lisps allow it.  The result is harder to debug code
> > and harder to instrument.
>
> I suspect all long-time Lispers have committed such sins at some point.
> I'm to blame for the godawful `vc-exec-after` example I sent earlier today.

I'd guess that's another class of blunder. Confusion about how lists
and lambda work is much more common in newcomers.

You can't forbid (funcall (list 'lambda)) without breaking lots of user
code, but do sth like coopt the existing "lexical-binding" variable to
introduce a  JS-like "strict mode".  I'm betting there's a correlation
between files with lexical-binding=nil and where these funcalls are
attempted or encouraged.

That's if you're interested in fixing this bit at all, which you don't
seem to be.

João



  reply	other threads:[~2024-01-30  8:58 UTC|newest]

Thread overview: 59+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-25 23:15 Distinguishing `consp` and `functionp` Stefan Monnier
2024-01-26  0:00 ` Adam Porter
2024-01-26  0:24   ` Stefan Monnier
2024-01-26  7:31 ` Eli Zaretskii
2024-01-26 19:22   ` João Távora
2024-01-26 21:13     ` Stefan Monnier
2024-01-26 21:50       ` João Távora
2024-01-26 23:55         ` Stefan Monnier
2024-01-27  0:22           ` Daniel Mendler via Emacs development discussions.
2024-01-27 11:47             ` João Távora
2024-01-27 13:20             ` Po Lu
2024-01-27 11:53           ` João Távora
2024-01-28  3:03           ` Richard Stallman
2024-01-28 21:27   ` Stefan Monnier
2024-01-29 12:45     ` Eli Zaretskii
2024-01-29 15:19       ` Stefan Monnier
2024-01-29 15:31         ` Eli Zaretskii
2024-01-29 15:41           ` Stefan Monnier
2024-01-29 15:46             ` Eli Zaretskii
2024-01-29 15:48               ` Stefan Monnier
2024-01-29 15:54             ` João Távora
2024-01-29 16:10               ` Eli Zaretskii
2024-01-29 16:25                 ` João Távora
2024-01-29 16:10               ` Eli Zaretskii
2024-01-29 16:17               ` Andreas Schwab
2024-01-29 16:34                 ` João Távora
2024-02-01  3:49                   ` Richard Stallman
2024-01-29 16:28               ` Stefan Monnier
2024-01-29 16:34                 ` João Távora
2024-01-29 20:00                   ` Stefan Monnier
2024-01-30  8:58                     ` João Távora [this message]
2024-01-30 12:54                       ` Stefan Monnier
2024-01-30 22:24                         ` João Távora
2024-01-30 23:13                           ` Stefan Monnier
2024-01-30 23:43                             ` João Távora
2024-01-31  0:22                               ` Stefan Monnier
2024-01-31  0:40                                 ` João Távora
2024-01-31  3:37                                   ` Stefan Monnier
2024-01-31 10:51                                     ` João Távora
2024-01-31 18:34                                       ` Stefan Monnier
2024-02-01  3:49                   ` Richard Stallman
2024-01-29 17:09             ` Yuri Khan
2024-02-01  3:49             ` Richard Stallman
2024-01-30  3:58     ` Richard Stallman
2024-01-27 11:00 ` Alan Mackenzie
2024-01-27 14:25   ` Stefan Monnier
2024-01-27 23:01     ` Alan Mackenzie
2024-01-28  0:00       ` Stefan Monnier
2024-01-28  6:12         ` Eli Zaretskii
2024-01-28 17:26         ` Alan Mackenzie
2024-01-28 17:48           ` Eli Zaretskii
2024-01-28 19:42             ` Alan Mackenzie
2024-01-28 20:08               ` Eli Zaretskii
2024-01-28 18:21           ` Stefan Monnier
2024-01-28 18:38           ` Stefan Monnier
2024-01-27 13:14 ` Po Lu
2024-01-27 14:41   ` Stefan Monnier
2024-01-28  1:56     ` Po Lu
2024-01-28 20:55     ` Stefan Kangas

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=CALDnm50QnCyeNwywqUOAn8GH6bsdrSqFXBaaJDDFSp6CxgxxyQ@mail.gmail.com \
    --to=joaotavora@gmail.com \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /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.
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).