unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Drew Adams <drew.adams@oracle.com>
To: Pip Cet <pipcet@gmail.com>, Paul Eggert <eggert@cs.ucla.edu>
Cc: "Basil L. Contovounesios" <contovob@tcd.ie>,
	Stefan Monnier <monnier@iro.umontreal.ca>,
	emacs-devel@gnu.org
Subject: RE: master f51f963: Fix some side-effecting uses of make-text-button
Date: Sat, 6 Jun 2020 09:57:23 -0700 (PDT)	[thread overview]
Message-ID: <170bedfa-7119-4d6a-9d4f-e94ba0f7cc2b@default> (raw)
In-Reply-To: <87img4zjy7.fsf@gmail.com>

> >> I get the impression we
> >> shouldn't discount the possibility that the current way of doing things
> >> (after pure space) isn't so bad at all: all strings, vectors, and cons
> >> cells are mutable to the same extent.
> >
> > That's not the current way of doing things, and although the area is
> > murky there have always been Emacs Lisp objects that are not mutable.
> 
> Lately, only pure ones, as far as I can tell?
> 
> > For example: (aset (symbol-name 'cons) 0 ?d)
> > This signals "Attempt to modify read-only object" error in Emacs 25, and
> > makes Emacs dump core in Emacs 27. And there are other cases like that.
> 
> Well, dumping core is bad. The problem here is how pdumper "changed"
> pure space (actually, we're putting several megabytes of zeroes into
> every Emacs binary as a result) and how make_pure_c_string tries so very
> hard to save a few kilobytes of memory. Both problems, as I said, that
> wouldn't exist if we simply removed pure space.
> 
> > Obviously we need to do better in the dumping-core area. When we do that,
> > we have an opportunity to simplify and/or document behavior in this area.
> 
> Indeed. Simplify: remove pure space. Document: all strings, vectors, and
> cons cells are mutable to the same extent.
> 
> > If we decide to simplify/document by saying "all strings are modifiable"
> > then we'll need significant work at both the C and Lisp level to do that.
> 
> I don't see why. All strings are modifiable, but the byte compiler will
> identify strings under certain circumstances. That doesn't violate the
> simple rule that as far as the Emacs core is concerned, all strings are
> equal.
> 
> > This will hurt performance a bit since it will disable some optimizations.
> 
> Which ones?
> 
> > If we decide to simplify/document by saying "an error is thrown if you try
> > to modify a string literal" then we'll need to add some code to do that. I
> > have a
> 
> So far, what you have proposed is "an error is thrown if you try to
> modify the characters of a string literal, or if you add text
> properties unless it already has some, or if you remove the last text
> property".
> 
> > draft of something along those lines. It doesn't hurt performance
> > significantly in my standard benchmark of 'make compile-always'.
> 
> (In general, I think that's probably not a good benchmark to optimize
> Emacs for).
> 
> > Although it invalidates some existing code, such code is quite
> > rare and is already relying on undefined behavior.
> 
> I'm not sure "undefined behavior" is a useful term when speaking about
> Emacs Lisp, except for behavior which is explicitly documented to be
> unreliable. There's a single implementation, and a lot of code is
> written to conform not to what's documented but to what happens to
> work.
> 
> > If we decide to leave things alone, they will remain complicated and murky.
> 
> But I'd call the behavior you suggest even more complicated.

Amen.

> I still think there's a significant risk that there will be ad-hoc
> changes that essentially commit us to a simplistic model of
> mutability. I don't think they're necessary or urgent, except for the
> make_pure_c_string bug you describe.
> 
> For example, I think it might be very useful to have an immutable "view"
> of a mutable object (as in C, where I can pass a char * to a function
> expecting a const char *); that would mean storing the mutability flag
> in the Lisp_Object, not in the struct Lisp_String.

+1.  All that Pip says here makes sense to me,
as far as I understand it.  (I can't speak to the
implementation matters, e.g. use of pure space.)

If someone has the cycles and will to improve
things by making the modification of strings,
including what look like literal strings in
code, easier and more flexible - in particular
text properties, great.

But going backwards, toward some perhaps unneeded
optimization, in the direction of systematically
raising an error when trying to modify text
properties of a string, is not a good idea, IMO.

Before even considering optimization there should
be some analysis of what would be gained and what
would be lost.

Yes, currently there is some mess and uncertainty.
But there are good and bad cures to mess and
uncertainty - different kinds of "cleanup".



  reply	other threads:[~2020-06-06 16:57 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20200604223056.17078.81265@vcs0.savannah.gnu.org>
     [not found] ` <20200604223058.1850020A26@vcs0.savannah.gnu.org>
2020-06-04 22:44   ` master f51f963: Fix some side-effecting uses of make-text-button Stefan Monnier
2020-06-05  0:58     ` Paul Eggert
2020-06-05  9:27       ` Pip Cet
2020-06-05 10:51     ` Basil L. Contovounesios
2020-06-05 12:46       ` Pip Cet
2020-06-05 13:51         ` Basil L. Contovounesios
2020-06-05 14:31           ` Pip Cet
2020-06-05 15:48             ` Basil L. Contovounesios
2020-06-05 18:17         ` Paul Eggert
2020-06-06  8:18           ` Pip Cet
2020-06-06 16:57             ` Drew Adams [this message]
2020-06-06 17:57               ` Stefan Monnier
2020-06-06 19:00                 ` Pip Cet
2020-06-06 19:49                   ` Paul Eggert
2020-06-06 20:23                     ` Drew Adams
2020-06-07  9:14                     ` Pip Cet
2020-06-06 22:14                   ` Stefan Monnier
2020-06-07  1:40                     ` Paul Eggert
2020-06-07 15:24                       ` Stefan Monnier
2020-06-07 23:42                         ` Paul Eggert
2020-06-07  9:31                     ` Pip Cet
2020-06-06 20:19                 ` Drew Adams
2020-06-06 17:54             ` Paul Eggert
2020-06-06 19:41               ` Pip Cet
2020-06-06 20:15                 ` Paul Eggert
2020-06-07  9:21                   ` Pip Cet
2020-06-07 23:37                     ` Paul Eggert
2020-06-06 20:11               ` Drew Adams
2020-06-06 22:16                 ` Stefan Monnier
2020-06-06 23:27                   ` Drew Adams
2020-06-05 13:02       ` Stefan Monnier
2020-06-05 13:50         ` Basil L. Contovounesios
2020-06-06 19:09         ` Paul Eggert
2020-06-06 20:19           ` Drew Adams

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=170bedfa-7119-4d6a-9d4f-e94ba0f7cc2b@default \
    --to=drew.adams@oracle.com \
    --cc=contovob@tcd.ie \
    --cc=eggert@cs.ucla.edu \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    --cc=pipcet@gmail.com \
    /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).