[Top][All Lists]

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

Re: Why does using aset sometimes output raw bytes?

From: Eli Zaretskii
Subject: Re: Why does using aset sometimes output raw bytes?
Date: Mon, 10 Dec 2018 07:59:52 +0200

> From: Stefan Monnier <>
> Date: Sun, 09 Dec 2018 16:20:59 -0500
> >> It's not the implementation, but the semantics of unibyte/multibyte
> >> strings presumes that the difference doesn't matter much for ASCII-only
> >> strings, which is mostly true but isn't true in the case of `aset`.
> > The same is true about concat, btw.
> I think it's less severe (`aset` can end up changing (by side-effect)
> a unibyte string to multibyte, i.e. changing the nature of the object,
> which I believe is the only time we do something like that), but yes
> similar problems appear elsewhere (hence the "mostly" above).

I'm not sure the "by side effect" part is an important distinction for
users, they might be surprised anyway.  For example:

  (let ((s1 "abcd")
        (s2 "абвг"))
    (message "s1: %s concat: %s"
             (multibyte-string-p s1)
             (multibyte-string-p (concat s1 s2))))
    => s1: nil concat: t

Some will say that this "converts" a unibyte string s1 to a multibyte
one just because it was concatenated.

People should always keep these gotchas in mind when working with

reply via email to

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