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: `aset` on strings, changing the size in bytes Date: Sun, 9 Sep 2018 12:27:21 -0400 Message-ID: References: <88must56x4.fsf@gnu.org> <83efe4trsa.fsf@gnu.org> <83lg8bsvfm.fsf@gnu.org> <83in3fqj9c.fsf@gnu.org> <83d0tmr97o.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" X-Trace: blaine.gmane.org 1536511238 12376 195.159.176.226 (9 Sep 2018 16:40:38 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 9 Sep 2018 16:40:38 +0000 (UTC) Cc: Emacs developers , Richard Stallman , Stefan Monnier To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Sep 09 18:40:34 2018 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 1fz2lF-00038s-M8 for ged-emacs-devel@m.gmane.org; Sun, 09 Sep 2018 18:40:33 +0200 Original-Received: from localhost ([::1]:48043 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fz2nM-0008Ad-60 for ged-emacs-devel@m.gmane.org; Sun, 09 Sep 2018 12:42:44 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:52500) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fz2m2-00084r-M5 for emacs-devel@gnu.org; Sun, 09 Sep 2018 12:41:23 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fz2YX-0007SN-C5 for emacs-devel@gnu.org; Sun, 09 Sep 2018 12:27:26 -0400 Original-Received: from mail-oi0-x22f.google.com ([2607:f8b0:4003:c06::22f]:32802) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fz2YU-0007Q7-Ty; Sun, 09 Sep 2018 12:27:23 -0400 Original-Received: by mail-oi0-x22f.google.com with SMTP id 8-v6so35846579oip.0; Sun, 09 Sep 2018 09:27:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=AehFyHC3toSSDuCjc2WsUJCrBbqCHIazwW2BXdaAT8A=; b=U6Xp3amXQ46+VKGSFAB3UxdNi2n+wm40rv3zdM0sKlKOY5zKqpqw4JOduE4ou5CubA U0CpLDlkgHqyKVzqLKs35Q9QINFi9kgSlM5DXTKjGS1qcfQ2Xjz6/Ljqves1cqmlwPnQ 15PuSU89qvRKEFtOMXqAdS5kXKYFE8rg61zeytR7irIwgSfdod4rZ7RxZZy0xG4ieIni ESf75G2AOZB6U3VfZPsFUEJ14OAR2DuwYLgyg5e0eRmYn9iWAixU8eK/SkSCCLqpmORT Gl2mrw07H5nLCZEVEdOcfCvpKunJeiLkaU34J6tgrxD9b9avDswBr6/UxoJ5Ujo6OiAL ryzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=AehFyHC3toSSDuCjc2WsUJCrBbqCHIazwW2BXdaAT8A=; b=sNvn/tPjrbkZzC9bZN9A20P5Bh4EkS0u0PBBhuweaFpTeLteuT1QSXqcDvQBKlSiVk bZOiQ0vejHuFRX57yu6Ddwzb70xpZRUHEwrZkyokgP3/mHgG5e2Go+E+u8/dQWrlS3uY gSxkCtaxO+csikgvkafDYl9btT/w2lvCGtYiNxq/GYCd3z148u2vTZCWRQwlpzrgZp1s Jp6rmK0jK7VcZxzrFl2WMMDfEf5DGtsDrSR5qrkeViDEHTvfaHr83GBumEsPLEBJTJk9 zXlTg4k3R94uB1SK25B3hxSXXQgb5FnTbuNbDgls8pKAIpkS9P3Hhq/Wjs+qmrWHNiqX iqvQ== X-Gm-Message-State: APzg51Dv03WjkG6aWzGiP800EMvEUTYOJliukWH3dgTe6WTSTQtDt5Lr Axxkmx+JdJe8N0KNoBHLHzcaidUUtOPZdgV/anNfag== X-Google-Smtp-Source: ANB0VdZM1Wi28n23wZkXFiXXNb3+eQYavi7q0b+yPYTKpsrsts/LSLUzomDogG31uIpzJYq2XnVtyH4jHMZWT5xPyBQ= X-Received: by 2002:aca:4a49:: with SMTP id x70-v6mr18674238oia.11.1536510442142; Sun, 09 Sep 2018 09:27:22 -0700 (PDT) Original-Received: by 2002:a9d:540f:0:0:0:0:0 with HTTP; Sun, 9 Sep 2018 09:27:21 -0700 (PDT) In-Reply-To: <83d0tmr97o.fsf@gnu.org> 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:229568 Archived-At: On 9 September 2018 at 11:17, Eli Zaretskii wrote: > I meant to make aset cons a new string when it turns out the original > one's data is too small to include the new contents. > >> the semantics of aset is to modify the original string, changing >> that would surely break code that worked for decades. > > But if we are going to tell people aset won't work in those cases, > that code will be broken as well, no? Ah, I think I see the disconnect. You mean aset should return a new string only in the case where the string needs to be resized (rather than signalling an error), but otherwise continue to modify the string in-place and return NEWELT as normal. A conditional return value like that seems too awkward to be useful, IMO. Instead of (setq s (sset s idx newchar)) ; as in [1] You would need: (let ((new-s (aset s idx newchar))) (when (stringp new-s) (setq s new-s))) In practice, I suspect people wouldn't bother a lot of the time, so in the rare case where a string is resized there will just be confusingly wrong answer instead of a clear error. [1]: https://lists.gnu.org/archive/html/emacs-devel/2018-09/msg00387.html