bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#64960: Documentation for copy-sequence


From: uzibalqa
Subject: bug#64960: Documentation for copy-sequence
Date: Mon, 31 Jul 2023 01:22:06 +0000

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


> > > It is not evident what the meaning of "shared" means ? If I use a
> > > string, I get an exact copy and when I change a single character
> > > the newlist is changed, the original string remains the same.
> > > So what is shared exactly ?
> > 
> > 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 ?






reply via email to

[Prev in Thread] Current Thread [Next in Thread]