From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: Optimize assume(...) away? (agaiin) Date: Wed, 09 Oct 2013 20:21:21 +0300 Message-ID: <83d2neqs1a.fsf@gnu.org> References: <525587A5.3040101@yandex.ru> Reply-To: Eli Zaretskii NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1381339297 1587 80.91.229.3 (9 Oct 2013 17:21:37 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 9 Oct 2013 17:21:37 +0000 (UTC) Cc: eggert@cs.ucla.edu, monnier@IRO.UMontreal.CA, emacs-devel@gnu.org To: Dmitry Antipov Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Oct 09 19:21:41 2013 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1VTxS8-0005ws-Si for ged-emacs-devel@m.gmane.org; Wed, 09 Oct 2013 19:21:40 +0200 Original-Received: from localhost ([::1]:43007 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VTxS8-0004qK-9a for ged-emacs-devel@m.gmane.org; Wed, 09 Oct 2013 13:21:40 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:59274) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VTxS0-0004pG-E0 for emacs-devel@gnu.org; Wed, 09 Oct 2013 13:21:36 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VTxRu-0001dZ-7m for emacs-devel@gnu.org; Wed, 09 Oct 2013 13:21:32 -0400 Original-Received: from mtaout21.012.net.il ([80.179.55.169]:43752) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VTxRt-0001cp-WF for emacs-devel@gnu.org; Wed, 09 Oct 2013 13:21:26 -0400 Original-Received: from conversion-daemon.a-mtaout21.012.net.il by a-mtaout21.012.net.il (HyperSendmail v2007.08) id <0MUE00200W1OJP00@a-mtaout21.012.net.il> for emacs-devel@gnu.org; Wed, 09 Oct 2013 20:21:24 +0300 (IDT) Original-Received: from HOME-C4E4A596F7 ([87.69.4.28]) by a-mtaout21.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0MUE002V7W7MIE30@a-mtaout21.012.net.il>; Wed, 09 Oct 2013 20:21:24 +0300 (IDT) In-reply-to: <525587A5.3040101@yandex.ru> X-012-Sender: halo1@inter.net.il X-detected-operating-system: by eggs.gnu.org: Solaris 10 X-Received-From: 80.179.55.169 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 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-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:164040 Archived-At: > Date: Wed, 09 Oct 2013 20:43:17 +0400 > From: Dmitry Antipov > CC: Stefan Monnier , > Eli Zaretskii , > Paul Eggert > > 1) http://lists.gnu.org/archive/html/emacs-devel/2013-10/msg00238.html > 2) http://debbugs.gnu.org/cgi/bugreport.cgi?bug=15565 > > 3) Consider non-trivial eassert like: > > eassert ((BUFFERP (it->object) > && IT_CHARPOS (*it) == it->bidi_it.charpos > && IT_BYTEPOS (*it) == it->bidi_it.bytepos) > || (STRINGP (it->object) > && IT_STRING_CHARPOS (*it) == it->bidi_it.charpos > && IT_STRING_BYTEPOS (*it) == it->bidi_it.bytepos) > || (CONSP (it->object) && it->method == GET_FROM_STRETCH)) > > a) It takes some time to check whether there are side effects here; > b) If someone change 'struct it' so IT_STRING_CHARPOS (*it) > becomes a non-trivial function with side effects, it would be > too annoying (and error-prone) to review all easserts. > > Due to 1), 2) and 3) I strongly suggests to redesign eassert > to avoid any assumptions about its argument expression. How about simply removing 'assume' from eassert? 'assume' is primarily an optimization device, and thus important in production builds of Emacs where optimizations are enabled. By contrast, eassert will be defined to nothing in such builds. So it sounds like we are at best optimizing a rare, or even non-existing use case, a.k.a. "premature optimization".