From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.bugs Subject: bug#46301: 28.0.50; cc-mode: add support for c++ lambda expression Date: Tue, 23 Feb 2021 19:19:28 +0000 Message-ID: References: <87czxfx2b9.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="34282"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 46301@debbugs.gnu.org To: Utkarsh Singh Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Feb 23 20:20:39 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1lEdEd-0008oK-2p for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 23 Feb 2021 20:20:39 +0100 Original-Received: from localhost ([::1]:56510 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lEdEc-00042Z-03 for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 23 Feb 2021 14:20:38 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:51280) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lEdE2-00042N-W1 for bug-gnu-emacs@gnu.org; Tue, 23 Feb 2021 14:20:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:49006) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lEdE2-0005vt-LW for bug-gnu-emacs@gnu.org; Tue, 23 Feb 2021 14:20:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lEdE2-0003xg-EW for bug-gnu-emacs@gnu.org; Tue, 23 Feb 2021 14:20:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Alan Mackenzie Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 23 Feb 2021 19:20:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 46301 X-GNU-PR-Package: emacs Original-Received: via spool by 46301-submit@debbugs.gnu.org id=B46301.161410797915194 (code B ref 46301); Tue, 23 Feb 2021 19:20:02 +0000 Original-Received: (at 46301) by debbugs.gnu.org; 23 Feb 2021 19:19:39 +0000 Original-Received: from localhost ([127.0.0.1]:60552 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lEdDe-0003x0-T2 for submit@debbugs.gnu.org; Tue, 23 Feb 2021 14:19:39 -0500 Original-Received: from colin.muc.de ([193.149.48.1]:11572 helo=mail.muc.de) by debbugs.gnu.org with smtp (Exim 4.84_2) (envelope-from ) id 1lEdDc-0003wn-Ux for 46301@debbugs.gnu.org; Tue, 23 Feb 2021 14:19:37 -0500 Original-Received: (qmail 60874 invoked by uid 3782); 23 Feb 2021 19:19:29 -0000 Original-Received: from acm.muc.de (p4fe15b08.dip0.t-ipconnect.de [79.225.91.8]) (using STARTTLS) by colin.muc.de (tmda-ofmipd) with ESMTP; Tue, 23 Feb 2021 20:19:29 +0100 Original-Received: (qmail 1248 invoked by uid 1000); 23 Feb 2021 19:19:28 -0000 Content-Disposition: inline In-Reply-To: <87czxfx2b9.fsf@gmail.com> X-Submission-Agent: TMDA/1.3.x (Ph3nix) X-Primary-Address: acm@muc.de X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:200681 Archived-At: Hello, Utkarsh. On Thu, Feb 04, 2021 at 21:17:22 +0530, Utkarsh Singh wrote: > Hi, > This bugs only occurs when we assign lambda expression as default > arguments in C++. I know there are better ways of using lambda but I > was just playing with both C++ and Emacs on a hobby project. > Consider this C++ code: > template > void bubble_sort(std :: vector &v, bool cmp(T, T)=[](T a, T b){return a < b;}) > { > bool swapped = true; > for(size_t i = 0; i < v.size() && swapped; i++) { > swapped = false; > for(size_t j = 0; j < v.size()-i; j++){ > if(cmp(v[j+1], v[j])) { > std::swap(v[j], v[j+1]); > swapped=true; > } > } > } > } > Here cmp takes a lambda as default argument and if in c++-mode if we try > using C-M-e(c-end-of-defun) it will get trapped into lambda. But from the end of that lambda, a further C-M-e takes point to the end of bubble_sort. Why do you think this is a bug? The lambda form is a function, it is at the top level (i.e. not within braces), so why shouldn't C-M-e stop at its end? That's a genuine question, by the way, not a rhetorical one. If anything, the rather unsystematic behaviour of C-M-a near this lambda function is of more concern. And there's the worry that this example will break other places where it's assumed that braces cannot occur in parameter lists. But of all the languages there are, trust C++ to be awkward. ;-) > To solve this is added c-forward-to-nth [ patch received with thanks, but snipped. ] > -- > Utkarsh Singh -- Alan Mackenzie (Nuremberg, Germany).