From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: Indentation of ?: in C-mode Date: Mon, 16 Jul 2018 11:54:17 -0400 Message-ID: References: <20180627182717.GA4625@ACM> <20180630190327.GC6816@ACM> <83tvpkkr93.fsf@gnu.org> <20180630201447.GE6816@ACM> <83o9frkmk7.fsf@gnu.org> <20180701163825.GC4697@ACM> <86bmbiceq7.fsf@stephe-leake.org> <86lgacswk8.fsf@stephe-leake.org> <83bmb8a5x0.fsf@gnu.org> <20180715184538.GC4897@ACM> <83601f9sdh.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1531756381 11889 195.159.176.226 (16 Jul 2018 15:53:01 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 16 Jul 2018 15:53:01 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Jul 16 17:52:57 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 1ff5o0-0002xx-PN for ged-emacs-devel@m.gmane.org; Mon, 16 Jul 2018 17:52:56 +0200 Original-Received: from localhost ([::1]:52533 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ff5q7-0002YP-Oh for ged-emacs-devel@m.gmane.org; Mon, 16 Jul 2018 11:55:07 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:39317) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ff5pP-0002XA-Bk for emacs-devel@gnu.org; Mon, 16 Jul 2018 11:54:24 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ff5pK-0001YS-HH for emacs-devel@gnu.org; Mon, 16 Jul 2018 11:54:23 -0400 Original-Received: from chene.dit.umontreal.ca ([132.204.246.20]:56461) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ff5pK-0001YJ-8t; Mon, 16 Jul 2018 11:54:18 -0400 Original-Received: from ceviche.home (lechon.iro.umontreal.ca [132.204.27.242]) by chene.dit.umontreal.ca (8.14.7/8.14.1) with ESMTP id w6GFsxRR009815; Mon, 16 Jul 2018 11:54:59 -0400 Original-Received: by ceviche.home (Postfix, from userid 20848) id 31408660E5; Mon, 16 Jul 2018 11:54:17 -0400 (EDT) In-Reply-To: <83601f9sdh.fsf@gnu.org> (Eli Zaretskii's message of "Mon, 16 Jul 2018 17:18:02 +0300") X-NAI-Spam-Flag: NO X-NAI-Spam-Threshold: 5 X-NAI-Spam-Score: 0 X-NAI-Spam-Rules: 2 Rules triggered EDT_SA_DN_PASS=0, RV6330=0 X-NAI-Spam-Version: 2.3.0.9418 : core <6330> : inlines <6750> : streams <1792724> : uri <2674506> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 132.204.246.20 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:227460 Archived-At: >> >> > + find_start_value >> >> > + = CONSP (state.levelstarts) ? XINT (XCAR (state.levelstarts)) >> >> > + : state.thislevelstart >= 0 ? state.thislevelstart >> >> > + : find_start_value; >> >> Please use parentheses here for better readability (to clearly show >> >> which parts belong to which condition). >> > Yes, it didn't indent well by itself. Maybe I should raise this with >> > the CC Mode maintainer. But yes, I'll put parens in. >> This is one of those rare cases where sm-c-mode handles it better: >> >> find_start_value >> = CONSP (state.levelstarts) ? XINT (XCAR (state.levelstarts)) >> : state.thislevelstart >= 0 ? state.thislevelstart >> : find_start_value; >> >> This said, I don't see either indentation as problematic and I'm not >> sure what would be "better for readability". > This: > > find_start_value = CONSP (state.levelstarts) > ? XINT (XCAR (state.levelstarts)) > : (state.thislevelstart >= 0 > ? state.thislevelstart > : find_start_value); Interesting: I find this one to be (ever so slightly) less readable. Basically, I read find_start_value = CONSP (state.levelstarts) ? XINT (XCAR (state.levelstarts)) : state.thislevelstart >= 0 ? state.thislevelstart : find_start_value; as a C version of (setq find_start_value (cond ((consp state.levelstarts) (XINT (XCAR (state.levelstarts)))) ((>= state.thislevelstart 0) state.thislevelstart) (t find_start_value))); so I find the ": condition ? value" lines to be very natural (the only odd line is really the first one because it doesn't start with ":"). Stefan PS: This was the opportunity to see that sm-c-mode misindents the last line of the middle example if you remove the parens: find_start_value = CONSP (state.levelstarts) ? XINT (XCAR (state.levelstarts)) : state.thislevelstart >= 0 ? state.thislevelstart : find_start_value; although now that I see it, I wonder if sm-c-mode.el read my mind and took ": condition ? value" as a logical entity, just to try and show me where this idea breaks down.