unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: uzibalqa via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: Drew Adams <drew.adams@oracle.com>
Cc: Dmitry Gutov <dmitry@gutov.dev>, Eli Zaretskii <eliz@gnu.org>,
	"64960@debbugs.gnu.org" <64960@debbugs.gnu.org>
Subject: bug#64960: Documentation for copy-sequence
Date: Mon, 31 Jul 2023 01:50:17 +0000	[thread overview]
Message-ID: <Ocr3qZcJjKDQgN_epUYjPEqWQlHzfdmEPyssqfIsdh529HKWzTbtNdCGtxatqIRMGsQ_YPCf9fLYHtPsM0Qap1O2R7EJiHFZYvBKqRycOAw=@proton.me> (raw)
In-Reply-To: <SJ0PR10MB5488C74BF3233286D1D88295F305A@SJ0PR10MB5488.namprd10.prod.outlook.com>

------- Original Message -------
On Monday, July 31st, 2023 at 1:36 PM, Drew Adams <drew.adams@oracle.com> wrote:


> > > > A string doesn't share anything because characters are not reference
> > > > values. They are simply copied.
> > > 
> > > Yes and no.
> > > Chars are not shared, but char properties are.
> > > 
> > > (setq foo (propertize "abcd" 'p1 t 'p2 42))
> > > ;; -> #("abcd" 0 4 (p2 42 p1 t))
> > > (setq bar (copy-sequence foo))
> > > ;; -> #("abcd" 0 4 (p1 t p2 42))
> > > (aset foo 1 ?W) ; -> ?W, aka 87
> > > foo ; -> #("aWcd" 0 4 (p2 42 p1 t))
> > > bar ; -> #("abcd" 0 4 (p1 t p2 42))
> > 
> > Ok, meaning that the actual string becomes different, yet changing
> > the a property, changes the property on both foo and bar ?
> 
> 
> No. I didn't change a property. I swapped one
> char for another. The doc says that the arg's
> "elements" are shared. A string's "elements"
> are its chars. But as Yuri pointed out, the
> chars themselves aren't shared, because they
> aren't sharable: they aren't references.

You only changed a character, which is not actually sharable.
But if I go change a property value for foo, I should see the
change also in bar, or not ?
 
> Strings can also have properties. We sometimes
> say that it's the characters that have the
> properties, but really it's that the properties
> are attached to the characters in the string or
> buffer - the properties are associated with
> string or buffer positions. The chars themselves
> don't really have properties. The properties are
> shared when you copy a string; the chars are not.

Meaning that I can make a copy of a string just to have 
the same properties (e.g, colour).
 
> This is really more of a natural-language nuance,
> about what it means for string elements to be
> shared. You can ignore it, if what I'm saying
> just confuses things.

Not too confusing, but required some attention.

Currently I am only interested in the actual characters
in my implementation where properties are not important.

Yet in my permute implementation I have seen that whether
I just use string or (copy-sequence string) does make a huge
difference.  Quite difficult to understand what's going on.





  reply	other threads:[~2023-07-31  1:50 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-30 16:42 bug#64960: Documentation for copy-sequence uzibalqa via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-07-30 18:36 ` Eli Zaretskii
2023-07-30 19:20   ` uzibalqa via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-07-30 19:59     ` Dmitry Gutov
2023-07-30 20:09       ` uzibalqa via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-07-30 20:15         ` Dmitry Gutov
2023-07-30 20:41           ` uzibalqa via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-07-31  1:13           ` Drew Adams
2023-07-31  1:22             ` uzibalqa via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-07-31  1:36               ` Drew Adams
2023-07-31  1:50                 ` uzibalqa via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2023-07-31  2:21     ` Eli Zaretskii
2023-07-31  2:31       ` uzibalqa via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-07-31  5:24         ` Michael Heerdegen
2023-07-31  6:19           ` uzibalqa via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-08-01  3:56             ` Michael Heerdegen
2023-08-13  4:27               ` Michael Heerdegen
2023-08-14 10:14                 ` uzibalqa via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-08-14 23:46                   ` Michael Heerdegen
2023-08-15  0:43                     ` uzibalqa via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-08-15 23:28                       ` Michael Heerdegen
2023-08-16  4:35                         ` uzibalqa via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-11 15:55                           ` Stefan Kangas
2023-07-31 14:34           ` 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='Ocr3qZcJjKDQgN_epUYjPEqWQlHzfdmEPyssqfIsdh529HKWzTbtNdCGtxatqIRMGsQ_YPCf9fLYHtPsM0Qap1O2R7EJiHFZYvBKqRycOAw=@proton.me' \
    --to=bug-gnu-emacs@gnu.org \
    --cc=64960@debbugs.gnu.org \
    --cc=dmitry@gutov.dev \
    --cc=drew.adams@oracle.com \
    --cc=eliz@gnu.org \
    --cc=uzibalqa@proton.me \
    /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).