unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Pip Cet <pipcet@gmail.com>
To: "Basil L. Contovounesios" <contovob@tcd.ie>
Cc: Stefan Monnier <monnier@iro.umontreal.ca>, emacs-devel@gnu.org
Subject: Re: master f51f963: Fix some side-effecting uses of make-text-button
Date: Fri, 05 Jun 2020 12:46:19 +0000	[thread overview]
Message-ID: <87img51y04.fsf@gmail.com> (raw)
In-Reply-To: <87eeqtiy4x.fsf@tcd.ie> (Basil L. Contovounesios's message of "Fri, 05 Jun 2020 11:51:26 +0100")

"Basil L. Contovounesios" <contovob@tcd.ie> writes:

> Stefan Monnier <monnier@iro.umontreal.ca> writes:
>>> @@ -202,7 +202,7 @@ The format has been repaired and the variable modified accordingly.
>>>  You can save the current value through the customize system by
>>>  either clicking or hitting return "
>>>            (make-text-button
>>> -           "here" nil
>>> +           (copy-sequence "here") nil
>>>             'face '(:weight bold :inherit button)
>>>             'mouse-face '(:weight normal :background "gray50" :inherit button)
>>>             'follow-link t
>>
>> So, here why do we need to `copy-sequence`?
>
> To avoid destructively modifying a string literal by placing properties
> on it.

I think adding a concept of mutability/constness/finality/... could be a
great extension of the ELisp language.

It would also be a very significant change of that language, perhaps
comparable to "true" multi-threading.

It would not be a quick bug fix for code that uses (propertize "string"
'a 'b).

In particular, I'm not convinced code like that is buggy at all. It's
true that it will fail under certain conditions (the string constant is
used again in the same function, the function is byte compiled, that
sort of thing), and it's true there are better ways of doing that, but
is that reason enough to off-handedly ban all such code?

I probably don't even know half of it, but there are so many overlapping
concepts ("const" in C, "constexpr" in C++, "final" in Java, "const" in
JavaScript, "frozen" objects in Python...) that 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.

I think it's worth it to experiment with other concepts of mutability,
perhaps on a feature branch, but I don't think that's true for a concept
that, so far, appears to be "literal strings can't be given text
properties unless they already have at least one, in which case you can
alter their text properties but not remove them all".

I'll take all of that back if I actually see a bug that means Lisp code
can cause an Emacs crash (in the C sense of "crash") by mutating literal
strings, and that can't easily be fixed in C, and isn't actually a known
limitation of the byte compiler.

My guess is a concept of immutability won't be very useful if it's just
a single bit telling you "this object is immutable": we need to attach
more information to it, perhaps going as far as providing special ways
of mutating the object rather than simply signalling an information-free
error. (So, for example, a vector could be defined in Lisp to coerce all
of its entries to nil or t, so we wouldn't need bool vectors anymore).

Sorry this got long, but I don't understand the rush to actually commit
to what appears to me to be a simplistic model of mutability when we
haven't even removed the previous one, which I believe we've outgrown:
pure space.

(I think we should also get rid of the hash table mutability thing
again, but that's another discussion entirely).



  reply	other threads:[~2020-06-05 12:46 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 [this message]
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
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=87img51y04.fsf@gmail.com \
    --to=pipcet@gmail.com \
    --cc=contovob@tcd.ie \
    --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).