From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Noam Postavsky Newsgroups: gmane.emacs.bugs Subject: bug#31715: cl-incf and cl-decf error out when passed a nil-valued variable as 'offset' Date: Tue, 05 Jun 2018 18:53:29 -0400 Message-ID: <87k1rc7sly.fsf@gmail.com> References: <1dff07f6-8da4-4e4c-a700-0bc39d6f2aa6@live.com> <874lii88hy.fsf@gmail.com> <87o9gqw21y.fsf@web.de> <871sdm851q.fsf@gmail.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1528239127 26519 195.159.176.226 (5 Jun 2018 22:52:07 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 5 Jun 2018 22:52:07 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) Cc: Michael Heerdegen , 31715@debbugs.gnu.org To: =?UTF-8?Q?Cl=C3=A9ment?= Pit-Claudel Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Jun 06 00:52:03 2018 Return-path: Envelope-to: geb-bug-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 1fQKo6-0006nj-8C for geb-bug-gnu-emacs@m.gmane.org; Wed, 06 Jun 2018 00:52:02 +0200 Original-Received: from localhost ([::1]:49485 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fQKqD-0006NP-Gw for geb-bug-gnu-emacs@m.gmane.org; Tue, 05 Jun 2018 18:54:13 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:57551) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fQKq6-0006N7-Ts for bug-gnu-emacs@gnu.org; Tue, 05 Jun 2018 18:54:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fQKq3-0007w1-Pl for bug-gnu-emacs@gnu.org; Tue, 05 Jun 2018 18:54:06 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:55910) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fQKq3-0007vr-Km for bug-gnu-emacs@gnu.org; Tue, 05 Jun 2018 18:54:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1fQKq3-00022D-AF for bug-gnu-emacs@gnu.org; Tue, 05 Jun 2018 18:54:03 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Noam Postavsky Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 05 Jun 2018 22:54:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 31715 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 31715-submit@debbugs.gnu.org id=B31715.15282392197790 (code B ref 31715); Tue, 05 Jun 2018 22:54:03 +0000 Original-Received: (at 31715) by debbugs.gnu.org; 5 Jun 2018 22:53:39 +0000 Original-Received: from localhost ([127.0.0.1]:35574 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fQKpf-00021a-GM for submit@debbugs.gnu.org; Tue, 05 Jun 2018 18:53:39 -0400 Original-Received: from mail-io0-f171.google.com ([209.85.223.171]:42676) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fQKpd-00021K-33 for 31715@debbugs.gnu.org; Tue, 05 Jun 2018 18:53:38 -0400 Original-Received: by mail-io0-f171.google.com with SMTP id r24-v6so5383182ioh.9 for <31715@debbugs.gnu.org>; Tue, 05 Jun 2018 15:53:36 -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=a08sZonMFqs4dy5lqNjn2NQWfw1HU+sqAvQxPyRfgSQ=; b=D23/wuWcReDQKk2xO0uFwO3ga+/AFyIvA4ucg6cesz5NoZLIEsfF14st8/bEwLm0pY E9hm+ujhQsrZpN7zATM75OW7O8GzBcXqdkiZFU9cgAa5XGNmr7htrnUDzsWMExePy1Wu ZI8uBNFtftWx2DKPjXyUhY3Tc4KV0iSkUHJMyyhh/hmy/qM1wbtMhUTkmVAJH/UXdKBu AohB16fW5w/1pl8qmmACeWPBsYvtmU9igyiD/dYif9zCVsj2jOTngo03mGfk6yJ3bEaZ IQ71xjA47R3vCLtmmPTuOEYOFSETLbZ1iL5XLRxXiZY7A4SLVdZvfNFUUrbpQlaGiyIk D5kA== 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=a08sZonMFqs4dy5lqNjn2NQWfw1HU+sqAvQxPyRfgSQ=; b=qMyEZI4W15iiL2gEewAk792f6CEZc3rtC5LLFUJJXw06qBVPLJjXqIzAafUmKn17gQ buTtmEU62zhR6kKs1GOxpMYRrsVqRqjUfRszt9UZO5CGs991oqbx7pVawn1Av/zI3lFP L1jSU+BtniuD6T5XteZ+Ykcw/SgtgiMAinVeZSnw8UtO5xmMjd8Tqbrd8EbIlEBCu1xY owkjjoYXekCrFePZNS3nGrWTz0Aa/tACszukDNNFCgYfqsVJuaBKIqrHRGu6c9itHWHp HJPB2PZQSMdx8NNdk1022pSt3fSVe23ypmR0hcXrSoX6CsMqU/y1bXwVOhEts2DQmEYD qVyw== X-Gm-Message-State: APt69E3jfrD6+YFFVb2KDbX5tsRHllJ1EmTpCsE8+aKxopT7NmFCbFD7 kvvZK1g2lmfFC8yqoL99KWfhwg== X-Google-Smtp-Source: ADUXVKJSj3VFBq1ESPG1f+ykHaLCQmJc0LHRzAU7xHM8SQotTEDMZjh8Ql/MYxCY3Cg6AVyA0F7HQA== X-Received: by 2002:a6b:380b:: with SMTP id f11-v6mr598052ioa.105.1528239211420; Tue, 05 Jun 2018 15:53:31 -0700 (PDT) Original-Received: from zebian (cbl-45-2-119-34.yyz.frontiernetworks.ca. [45.2.119.34]) by smtp.googlemail.com with ESMTPSA id h81-v6sm66577ith.2.2018.06.05.15.53.29 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 05 Jun 2018 15:53:30 -0700 (PDT) In-Reply-To: ("=?UTF-8?Q?Cl=C3=A9ment?= Pit-Claudel"'s message of "Tue, 5 Jun 2018 11:19:22 -0400") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:147046 Archived-At: Cl=C3=A9ment Pit-Claudel writes: > On 2018-06-04 18:58, Noam Postavsky wrote: >> X is an optional macro parameter, so the "optionalness" applies at >> compile time. > > I think I see what you mean, but I'm not entirely convinced (in part > because the docstring doesn't say so, and in part because it doesn't > seem worth it to break referential transparency: if we accept nil, we > should also accept a variable that evaluates to nil). Hmm, not sure if referential transparency makes much sense for macros. Both SBCL and CLisp throw an error for (let ((x 1) (y nil)) (incf x y)), although I can't see anything in the Common Lisp spec to decide either way. E.g., cltl2 says: If delta is not supplied, then the number in place is changed by 1. https://www.cs.cmu.edu/Groups/AI/html/cltl/clm/node125.html >> I think that would approximately double the cost of cl-incf in the >> simple case. And since you would expect cl-incf to be used in loops a >> lot, that seems like a bad idea. > > I think we could still optimize the case in which we get an explicit nil. As I wrote earlier, I was wrong about the optimization thing anyway (I initially looked at the macro expansion output instead of the byte compiler output). > In the rest of Emacs there are lots of other examples. Many of them > (for example semantic-find-tags-by-name or calendar-increment-month) > seem to work when passed a nil-valued variable, but many others behave > like cl-incf (for example gnus-summary-article-score). I don't think those are great examples of macros to emulate. semantic-find-tags-by-name and gnus-summary-article-score look like they should be (inline?) functions instead of macros. calendar-increment-month doesn't use make-symbol for proper temp variable hygiene.