unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Michael Heerdegen <michael_heerdegen@web.de>
To: Jean-Christophe Helary <lists@traduction-libre.org>
Cc: emacs-devel <emacs-devel@gnu.org>
Subject: Re: lexical binding?
Date: Mon, 25 Oct 2021 14:08:22 +0200	[thread overview]
Message-ID: <87mtmxs3wp.fsf@web.de> (raw)
In-Reply-To: <35E8DC30-8C38-4D74-840A-BBAFDEBA7357@traduction-libre.org> (Jean-Christophe Helary's message of "Sun, 24 Oct 2021 10:09:57 +0900")

Jean-Christophe Helary <lists@traduction-libre.org> writes:

> What is the issue with using setq on undefined symbols? Can that break
> things eventually?

If you do this, it will soon become impossible to find out
when the values of referenced variables were set and by what code.  Such
a programming style would lead to unreadable and hard-to-debug code.
Not because others are not used to this kind of style - it's really
harder to do.

> Is that related to lexical binding?

Not really.  You have dynamically binding global variables in both the
lexical binding and the dynamically binding dialect of Elisp, and what
you suggest leads to the same problems in both dialects.

OTOH, it is a bit related.  Bindings to lexical variables can be tracked
most easily by a programmer - you can just look at the text to see where
in your code a binding is established.

Dynamical variables are worse, but it's still easy to track dynamical
bindings using a debugger.  You must just look for binding forms
currently processed in the backtrace, and which function called them.

Only using dynamically binding global variables is the most primitive
way of handling computer memory.  Calculators from the 90s had this:
global registers A, ..., Z.  You can't even write recursive functions
using only a limited number of global variables.  And a debugger doesn't
help you much understanding such code.  You must run the complete
program and track set variables to understand what is going on.

So this kind of thing should be avoided wherever possible.

Michael.



      parent reply	other threads:[~2021-10-25 12:08 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-24  1:09 lexical binding? Jean-Christophe Helary
2021-10-24 13:32 ` Stefan Monnier
2021-10-25 12:46   ` Jean-Christophe Helary
2021-10-25 22:55     ` Stefan Monnier
2021-10-25 14:46   ` Jean-Christophe Helary
2021-10-25 17:17     ` Stefan Monnier
2021-10-25 12:08 ` Michael Heerdegen [this message]

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=87mtmxs3wp.fsf@web.de \
    --to=michael_heerdegen@web.de \
    --cc=emacs-devel@gnu.org \
    --cc=lists@traduction-libre.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 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).