From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= Newsgroups: gmane.emacs.devel Subject: Re: 31395511: =?utf-8?Q?=22Don=E2=80=99t?= attempt to modify constant strings" Date: Fri, 05 Jun 2020 16:25:28 +0100 Message-ID: <873679lel3.fsf@gmail.com> References: <871rmvn7ge.fsf@gmail.com> <87lfl36abx.fsf@gmail.com> <1abe5965-b48e-6dee-1516-c5c233f09d01@cs.ucla.edu> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="55141"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: Pip Cet , emacs-devel To: Paul Eggert Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Jun 05 17:26:09 2020 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jhEET-000EEy-Ob for ged-emacs-devel@m.gmane-mx.org; Fri, 05 Jun 2020 17:26:09 +0200 Original-Received: from localhost ([::1]:42460 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jhEES-0001yf-Rh for ged-emacs-devel@m.gmane-mx.org; Fri, 05 Jun 2020 11:26:08 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:54856) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jhEDv-0001F3-Id for emacs-devel@gnu.org; Fri, 05 Jun 2020 11:25:35 -0400 Original-Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]:32915) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jhEDu-0006Sj-EM for emacs-devel@gnu.org; Fri, 05 Jun 2020 11:25:35 -0400 Original-Received: by mail-wm1-x32e.google.com with SMTP id j198so9345659wmj.0 for ; Fri, 05 Jun 2020 08:25:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-transfer-encoding; bh=MpnJTq99PgatdBH3X567bWGLC+wV4TQZo55zTy1041w=; b=P9kDKYLdrbTEAK1Tlpc91d5kRE0oY6RN7qQ8oelt9Y6OPMOsst3bqmBNjJI4KRTs17 5xWVjSFvegkD3iPF5YgtWpOnG8K/Dn5eVFyl4S/B5cZ2QY+kOsa3shlyAITD7gukAT4n zbR2m7fzecs/H1EZ1YpwlyTwQQnA5UsTZ9QXiPFh2DRLS8BluS0YuI6MKo9pWmYEjxZR h51MM63HdV+53Io8PmTUVMDbryWhaeQK6Kv6VMzt0yGAJnOznBnuizervLE1B5iEILgc B3akwj1J3jXADAGJkxi7MSRxOvxzczA7wffPYgihj3C1ZEDjJS95u6PcGArELvY586Ub 7wsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-transfer-encoding; bh=MpnJTq99PgatdBH3X567bWGLC+wV4TQZo55zTy1041w=; b=dhU5Cv/b2RXpPyITpxXZ7pQ/eET4oCdOXh2l3fm84u8bLP/V6IjaIgWBwn8DDjGIws aceEAQP5XK7bS54/gQyen6+En4WXtSRJ4PP8z+Y1nwizp3Saj+gnfw8jFlTRWNOyJ1qm 70rJc+G3bC9/0jt79uY+yBnVDtwmhvI3PirtprBqUUspM3Iz47vZDe2G4im2Xig82exJ rdTonpMB1DWlyq7gx5KgnPw75q50QQWGGlH1EnjKIa5FnefqnVVEHLu44CrYcD8T7SMc XSBGFlA4YJVvaknw0OIiQF2Sl+Un8N/Ah5aJ4yekUdvCprvGChPMC5X6z+oR1oiQtSoX Xl7g== X-Gm-Message-State: AOAM532upO5C1mUThu/ysuuXIxOyV17yuOszKr2v/vFO0ndRtsj1o2cR PkaesL/mMl9qMAD8sfPZ9Mn3lrwvC4M= X-Google-Smtp-Source: ABdhPJyQ2RFivMPsRGeSpjo2ebciX0fxAkGSziZOpt151Nek6gZRLmbpcIacEEHlpC5to3d0elpiSw== X-Received: by 2002:a05:600c:24c:: with SMTP id 12mr3366946wmj.28.1591370732479; Fri, 05 Jun 2020 08:25:32 -0700 (PDT) Original-Received: from krug ([89.180.147.0]) by smtp.gmail.com with ESMTPSA id o6sm12624166wrp.3.2020.06.05.08.25.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jun 2020 08:25:31 -0700 (PDT) In-Reply-To: <1abe5965-b48e-6dee-1516-c5c233f09d01@cs.ucla.edu> (Paul Eggert's message of "Wed, 3 Jun 2020 17:43:32 -0700") Received-SPF: pass client-ip=2a00:1450:4864:20::32e; envelope-from=joaotavora@gmail.com; helo=mail-wm1-x32e.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, FROM_EXCESS_BASE64=0.979, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 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-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:251906 Archived-At: Paul Eggert writes: > On 6/3/20 4:48 PM, Jo=C3=A3o T=C3=A1vora wrote: >> I think I'd rather this previous behavior were retained, or at least >> achievable by request. > > It's tricky, as make-text-button in emacs-27 (and earlier) modifies its s= tring > argument, which is buggy because string constants are not always unique. = For > example: > > (defun example-bug () > (concat "1. " (make-text-button > "example" nil > 'action (lambda (_) (message "action 1"))) > "2. " (make-text-button > "example" nil > 'action (lambda (_) (message "action 2"))))) > > If you byte-compile this in emacs-27, both buttons message "action 2" bec= ause > there's there's really just one instance of the string constant "example"= , and > so there's just one button and the second action overwrites the first. But if you evaluate it, that doesn't happen, which is probably even worse. And this is even stranger, IMO: (defun example-bug2 () (eq (make-text-button "example" nil 'action (lambda (_) (message "action 1"))) (make-text-button "example" nil 'action (lambda (_) (message "action 2"))))) =20=20=20=20=20 (defun example-bug3 () (eq "example" "example")) =20=20=20=20=20 (defun example-bug4 () (let ((str1 "example") (str2 "example")) (eq str1 str2))) =20=20=20=20=20 (list (example-bug2) (example-bug3) (example-bug4)) when compiled, last form returns (t nil t) in emacs 27, when compiled, last form returns (nil nil t) in emacs 28. when evaluated, last form returns (nil nil nil) in emacs 28. For comparison, example-bug4 is valid Common Lisp and will return nil in every Common Lisp implementation I know (I tested with ACL and SBCL), regardless of whether compiled or evaluated. I'm reasonably confident there's somewhere in the Hyperspec where that behaviour may be specified (I trust some CL pope will find it for me ;-) ) Elisp is its own Lisp of course, and I suppose these things allow for performance/space optimizations under the hood, but is all that strange behaviour worth it? > Does SLY always pass mutable strings to make-text-button? I.e., strings b= uilt > from 'concat' etc. (not string constants)? If so, I could change > make-string-button to copy its string argument only if it's a constant, a= nd that > should fix the compatibility issue without needing to make any changes > to SLY. No it doesn't, as someone else has already reported. Jo=C3=A3o