[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: master f51f963: Fix some side-effecting uses of make-text-button
From: |
Pip Cet |
Subject: |
Re: master f51f963: Fix some side-effecting uses of make-text-button |
Date: |
Sat, 06 Jun 2020 19:41:41 +0000 |
User-agent: |
Gnus/5.13 (Gnus v5.13) |
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.
- Re: master f51f963: Fix some side-effecting uses of make-text-button, (continued)
- Re: master f51f963: Fix some side-effecting uses of make-text-button, Paul Eggert, 2020/06/04
- Re: master f51f963: Fix some side-effecting uses of make-text-button, Basil L. Contovounesios, 2020/06/05
- Re: master f51f963: Fix some side-effecting uses of make-text-button, Paul Eggert, 2020/06/05
- Re: master f51f963: Fix some side-effecting uses of make-text-button, Pip Cet, 2020/06/06
- Re: master f51f963: Fix some side-effecting uses of make-text-button, Paul Eggert, 2020/06/06
- Re: master f51f963: Fix some side-effecting uses of make-text-button,
Pip Cet <=
- Re: master f51f963: Fix some side-effecting uses of make-text-button, Paul Eggert, 2020/06/06
- Re: master f51f963: Fix some side-effecting uses of make-text-button, Pip Cet, 2020/06/07
- Re: master f51f963: Fix some side-effecting uses of make-text-button, Paul Eggert, 2020/06/07
- RE: master f51f963: Fix some side-effecting uses of make-text-button, Drew Adams, 2020/06/06
- Re: master f51f963: Fix some side-effecting uses of make-text-button, Stefan Monnier, 2020/06/06
- RE: master f51f963: Fix some side-effecting uses of make-text-button, Drew Adams, 2020/06/06
- RE: master f51f963: Fix some side-effecting uses of make-text-button, Drew Adams, 2020/06/06
- Re: master f51f963: Fix some side-effecting uses of make-text-button, Stefan Monnier, 2020/06/06
- Re: master f51f963: Fix some side-effecting uses of make-text-button, Pip Cet, 2020/06/06
- Re: master f51f963: Fix some side-effecting uses of make-text-button, Paul Eggert, 2020/06/06