From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.help Subject: Re: Why does using aset sometimes output raw bytes? Date: Mon, 10 Dec 2018 07:59:52 +0200 Message-ID: <83in013orr.fsf@gnu.org> References: <87h8fmohmo.fsf@gmx.net> <871s6qobvm.fsf@gmx.net> <83lg4y30vz.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: blaine.gmane.org 1544421512 19789 195.159.176.226 (10 Dec 2018 05:58:32 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 10 Dec 2018 05:58:32 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Dec 10 06:58:28 2018 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gWEaJ-00052K-OU for geh-help-gnu-emacs@m.gmane.org; Mon, 10 Dec 2018 06:58:27 +0100 Original-Received: from localhost ([::1]:59301 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gWEcQ-0001ZH-Ba for geh-help-gnu-emacs@m.gmane.org; Mon, 10 Dec 2018 01:00:38 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:44141) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gWEbx-0001ZB-HV for help-gnu-emacs@gnu.org; Mon, 10 Dec 2018 01:00:11 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gWEbt-0006W9-Hx for help-gnu-emacs@gnu.org; Mon, 10 Dec 2018 01:00:09 -0500 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:57508) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gWEbt-0006W3-CE for help-gnu-emacs@gnu.org; Mon, 10 Dec 2018 01:00:05 -0500 Original-Received: from [176.228.60.248] (port=2026 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1gWEbs-0001Om-Sd for help-gnu-emacs@gnu.org; Mon, 10 Dec 2018 01:00:05 -0500 In-reply-to: (message from Stefan Monnier on Sun, 09 Dec 2018 16:20:59 -0500) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:118955 Archived-At: > 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 strings.