From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Noam Postavsky Newsgroups: gmane.emacs.devel Subject: Re: Obsolete string-to-multibyte hard to replace Date: Mon, 29 May 2017 20:21:01 -0400 Message-ID: References: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" X-Trace: blaine.gmane.org 1496103713 1343 195.159.176.226 (30 May 2017 00:21:53 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 30 May 2017 00:21:53 +0000 (UTC) Cc: Emacs developers To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue May 30 02:21:49 2017 Return-path: Envelope-to: ged-emacs-devel@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 1dFUuz-0000EI-OH for ged-emacs-devel@m.gmane.org; Tue, 30 May 2017 02:21:49 +0200 Original-Received: from localhost ([::1]:50962 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dFUv5-0008Gd-5m for ged-emacs-devel@m.gmane.org; Mon, 29 May 2017 20:21:55 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:58478) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dFUuG-0008GT-TB for emacs-devel@gnu.org; Mon, 29 May 2017 20:21:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dFUuF-0005aK-Q1 for emacs-devel@gnu.org; Mon, 29 May 2017 20:21:04 -0400 Original-Received: from mail-oi0-x22f.google.com ([2607:f8b0:4003:c06::22f]:33911) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dFUuF-0005Zk-DE for emacs-devel@gnu.org; Mon, 29 May 2017 20:21:03 -0400 Original-Received: by mail-oi0-x22f.google.com with SMTP id b204so93296508oii.1 for ; Mon, 29 May 2017 17:21:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=zEDfrgSO8AcH9begat/xsYtpwzO5Ht3aEdr+fE+taIQ=; b=WEs90wBiiL/VV7uVyHnEByOwwGAw7Jtn7a62SEmllnz0WlpdPG4sMOlXwy2oGI9bkd aYXWn7yCU0IwH9HXUR1Umm2zBLbBa7Cfy5/jUq48CiJUSEj9Wyx83uWGMFzktpFKxExi 66brdYfJVdBZ1ewCtVgxuFU5NLOoc40nYlYW8optMQGM9F8obOA7XcJurW3hzSzsKq0z 0LHpy4klrGrHMyewdRAju3nKSY2QLD2ikWp1GPAkE26nFBTayJEPrbIB+q5A4Eeux7Kd cvADbs3HkoUvUx3o4EoIsf4T8LE+b86z//5IFbwCXA5d15pvF1wKyQOhNwh11euRMtsj EYmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=zEDfrgSO8AcH9begat/xsYtpwzO5Ht3aEdr+fE+taIQ=; b=mzVj4uoTS5dtmgywG3sfuJRWZbaLx6zpzS7ZAebd+9dl7+vU02WOsvKLaFiSgSi/9H beIjw6vwgWO9CZttrXz5+iQyTuDcRgi6Z0LVSqYvdXZX0YzNaanpnLqoO/faqnQDQsd3 Nrk2ckC4OIAU5DwK3hIJDHPHzmZ1yxLuEztH/ME4LW2GYI4GWMGEMLLJuipXnfi6Ny/6 EIqtHPue3ibOMhD9SjMK+N3nb279EjGEcgRxUSgpuWN33RCrSJVZ1nNN5DdTFWhMT9sL tn4rP1bGzx2gf9Su/1qEfi9erbqt+rw5+AaRUYU4Sq1gJf++m07whJEJmvQ7s+HaVBGq wvUw== X-Gm-Message-State: AODbwcAL6a3dmXmSXMKcaRk3QKhvabCdzjPd3JLYID21tY/tD2gO6GBg +j7K/vgt0BrinvufU+L0QcLvpiE9rQ== X-Received: by 10.202.197.205 with SMTP id v196mr6802611oif.37.1496103662702; Mon, 29 May 2017 17:21:02 -0700 (PDT) Original-Received: by 10.74.139.83 with HTTP; Mon, 29 May 2017 17:21:01 -0700 (PDT) In-Reply-To: X-Google-Sender-Auth: midNX9WoUUA3i25ymFYZ79gGfr8 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::22f X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:215331 Archived-At: On Mon, May 29, 2017 at 9:01 AM, Stefan Monnier wrote: > I was looking at ruler-mode.el's bytecomp warning about string-to-multibyte > and it seems like there is no good way to write cleaner code here: > > (let (... > (ruler > (propertize > (string-to-multibyte > (make-string w ruler-mode-basic-graduation-char)) > ...)) > ...) > [...] > (aset ruler k (aref c (setq m (1- m)))) > > Here, the problem is as follows: make-string returns a unibyte string if > the initial char is ASCII and a multibyte string otherwise. > Seems innucuous, but it means that if the initial char > (ruler-mode-basic-graduation-char above) is ASCII, you can't later > insert a multibyte char into that string with `aset`. We could the collect the characters in a vector and then only convert to string at the end. Haven't you said that strings should ideally be treated as immutable?