all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Po Lu <luangruo@yahoo.com>
To: abq@bitrot.link
Cc: Eli Zaretskii <eliz@gnu.org>,  emacs-devel@gnu.org
Subject: Re: Why is lexical-binding's global value ignored?
Date: Mon, 30 Jan 2023 21:45:25 +0800	[thread overview]
Message-ID: <87cz6wyw3u.fsf@yahoo.com> (raw)
In-Reply-To: <43216edcfeada34083e17a8230af2ee3@bitrot.link> (abq@bitrot.link's message of "Sun, 29 Jan 2023 20:53:30 -0700")

abq@bitrot.link writes:

> Then it breaks! As I wrote in my response to tomas: “In order to break
> anything, you would have to do so explicitly, via (setq-default
> lexical-binding t).”
>
> Of course, nobody actually does that. Therefore, it would be safe to
> honor the global value in Emacs 29.
>
> And the reason nobody sets the global value is that currently it would
> be pointless, because it isn't honored in Emacs 24 through 28.
>
> There's no danger of anybody accidentally setting it with plain setq,
> since it automatically becomes buffer local when set. You have to
> purposefully shoot yourself in the foot with setq-default.

[...]

> But of course, dynamic binding isn't always used intentionally. It's
> also often used in cases where the programmer gave no consideration to
> the difference (and often, unconsciously intended lexical
> binding). Since the longstanding, widespread computer science
> consensus is to program using lexical binding except in special cases
> where dynamic binding is intentionally chosen, it's sensible to
> facilitate a bias in that direction, at least optionally.
>
> If you use lots of historical code written with no consideration of
> the difference, one way to test the code would be to sprinkle
> lexical-binding: t across the tops of all your files, and keep track
> of which ones have it set because they actually expect it vs. which
> ones have it set just so you can test them. Which, ironically, is a
> bit like using a purely functional language with no dynamic binding or
> global variables, so you're forced to modify all your function
> signatures and calls to explicitly pass global state as an argument.
>
> Or, a more sensible way to test your historical code would be to
> simply do (setq-default lexical-binding t) in your init file. But you
> can't do that in Emacs 24 through 28, because the global value is
> ignored.
>
> If it were honored in Emacs 29, then a news item could be added,
> suggesting everybody try (setq-default lexical-binding t) in the init
> file, to test all the packages they use, then add explicit
> lexical-binding: nil (or defvar) in the cases where dynamic binding is
> intentional. People who think this is nonsense can harmlessly ignore
> the suggestion.

And why would you want to break it?
I think most of Drew Adam's packages do not use lexical binding.

Neither does much of the code which comes with other GNU software,
such as the major mode GMP provides to edit its special assembler
macros.

We must not deliberately break such software!



  parent reply	other threads:[~2023-01-30 13:45 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-28  3:01 Why is lexical-binding's global value ignored? abq
2023-01-28  7:10 ` tomas
2023-01-29  9:36   ` Jean Louis
2023-01-31  4:19     ` Richard Stallman
2023-01-31 13:49       ` Eli Zaretskii
2023-01-28 16:11 ` abq
2023-01-28 18:44   ` tomas
2023-01-28 22:34   ` abq
2023-01-29  6:54     ` Eli Zaretskii
2023-01-30  3:53       ` abq
2023-01-30 12:32         ` Eli Zaretskii
2023-01-30 12:59           ` tomas
2023-01-30 13:45         ` Po Lu [this message]
2023-02-01  2:04     ` abq

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87cz6wyw3u.fsf@yahoo.com \
    --to=luangruo@yahoo.com \
    --cc=abq@bitrot.link \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@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.
Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.