unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Pip Cet <pipcet@gmail.com>
To: 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, 06 Jun 2020 19:41:41 +0000	[thread overview]
Message-ID: <87lfl0x9qi.fsf@gmail.com> (raw)
In-Reply-To: <1742051d-ff33-fe97-d0ee-83f55847d98a@cs.ucla.edu> (Paul Eggert's message of "Sat, 6 Jun 2020 10:54:46 -0700")

Paul Eggert <eggert@cs.ucla.edu> writes:

> On 6/6/20 1:18 AM, Pip Cet wrote:
>
>>> there have always been Emacs Lisp objects that are not mutable.
>> 
>> Lately, only pure ones, as far as I can tell?
>
> There are others. I haven't cataloged them but they include builtin symbol
> names

pure

> empty strings,

pure, and as modifiable as all other strings

> and constant variables (no, I didn't come up with that
> last term :-). Also numbers of course.

I don't think setting a symbol's values is comparable to mutating a
vector or string.  Neither are numbers.

> Constants have always been
> ubiquitous in
> Emacs.

I disagree, to me immutable objects appear to be the strange exception.

>>> 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's not how Emacs works now,

Very close, though.

> and it's not how Common Lisp or Scheme works.

Neither is anything that has been proposed by you so far.

> If
> we insisted on making the change you're proposing, it would throw yet another
> obstacle into the path of porting Emacs to other platforms such as Guile. That
> would not be a good road to take.

"Yet another" is the important term here, I think. There are more
significant issues to sort out.

> It might be worth making such a significant change if modifiable
> string literals
> were an important feature that Elisp programmers urgently needed. But they're
> not: they're rarely used, partly because when they have been used their use
> often caused subtle bugs (as we've seen with make-text-button). They're not a
> feature worth fighting for, any more than mutable numbers would be.

I agree, actually. What I'm fighting against is a certain model of
immutability being installed into the Emacs source tree and effectively
preventing better ones from ever having a chance, as well as turning out
to be, as the vast majority of such models have, a problem rather than a
useful feature.

>
>>> This will
>>> hurt performance a bit since it will disable some optimizations.
>> 
>> Which ones?
>
> The ones Emacs is currently using, such as some strings are in
> read-only shared
> memory,

I don't think that's even an optimization. As I said, we're not
aggressively reducing the size of the Emacs binary, quite the opposite,
and read-only strings copied into pure space probably wouldn't be paged
in.

> and some are coalesced.

Just to be clear: nothing in Emacs "coalesces" two strings by making
them equal if they weren't before. The byte compiler generates new
strings, and might generate fewer than were put in, but a string always
has its own identity and keeps it.

> It would be unreasonable to coalesce
> strings if
> they were mutable, since that would mean changing one would change the
> other.

Strings are mutable, and we are "coalescing" them, if only in the weak
sense that the byte compiler does.

>
>> 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".
>
> There must be some confusion here, as I haven't proposed that.

I'm sorry for misunderstanding, then.

> What
> I'm thinking
> of proposing (though I haven't written it up yet, and this is just an
> off-the-cuff first cut) is that Emacs signal an error if a program attempts to
> change a string constant's characters or text properties.

Okay. I'm sorry I assumed you were just going to go ahead and commit
something without any prior discussion, and it would be unfair not to
wait for that proposal before criticizing it.

>> (In general, I think that's probably not a good benchmark to optimize
>> Emacs for).
>
> Admittedly it's crude but it is better than nothing and it is what we have
> readily available. If you have another easy-to-use benchmark that would be
> better, I'm all ears.

Let me second that, I would love to have a better benchmark.

>> 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.
>
> Of course, and there's a natural tension between trying to document every
> unimportant implementation detail (which would be a mistake) and not
> documenting
> useful behavior (which would also be a mistake). But that's not the
> issue here,
> as the behavior in question is explicitly documented to be unreliable
> and we're
> discussing what (if anything) to do about it.

I'm not sure whether I've lost the right to comment on changes made all
of six weeks ago, because I must admit I hadn't been aware of those
documentation changes. I think you've essentially documented the changes
you're considering to propose as though they had already happened.

I think there are solutions here we'd both be happy with: we can easily
use the C preprocessor to generate the amount of mutability checking we
want, ignoring all or some of the information passed to the macros.

But if we want that C API to be flexible enough to allow unusual
applications (and isn't that what Emacs is all about?), it needs
something more than just the obvious CHECK_MUTABLE (obj) macro.



  reply	other threads:[~2020-06-06 19:41 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
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 [this message]
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=87lfl0x9qi.fsf@gmail.com \
    --to=pipcet@gmail.com \
    --cc=contovob@tcd.ie \
    --cc=eggert@cs.ucla.edu \
    --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).