From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: David Engster Newsgroups: gmane.emacs.devel Subject: Re: Emacs contributions, C and Lisp Date: Wed, 26 Feb 2014 17:28:23 +0100 Message-ID: <87a9ddg7o8.fsf@engster.org> References: <20140216180712.236069f6@forcix.jorgenschaefer.de> <87wqgr4v18.fsf@yandex.ru> <53064BD0.7070009@yandex.ru> <87ha7tr5bo.fsf@fencepost.gnu.org> <87ppmhecd8.fsf@yandex.ru> <87y50z90pd.fsf@fencepost.gnu.org> <87txbn8r6x.fsf@fencepost.gnu.org> <8338j717oe.fsf@gnu.org> <87zjlf6tdx.fsf@fencepost.gnu.org> <83sir7yue7.fsf@gnu.org> <8761o3dlak.fsf@wanadoo.es> <83bnxuzyl4.fsf@gnu.org> <871tyqes5q.fsf@wanadoo.es> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1393432129 1895 80.91.229.3 (26 Feb 2014 16:28:49 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 26 Feb 2014 16:28:49 +0000 (UTC) Cc: emacs-devel@gnu.org To: =?iso-8859-1?Q?=D3scar?= Fuentes Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Feb 26 17:28:58 2014 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 1WIhLs-0004TK-4G for ged-emacs-devel@m.gmane.org; Wed, 26 Feb 2014 17:28:56 +0100 Original-Received: from localhost ([::1]:41576 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WIhLr-0001JU-NR for ged-emacs-devel@m.gmane.org; Wed, 26 Feb 2014 11:28:55 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:37515) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WIhLf-00017P-Hx for emacs-devel@gnu.org; Wed, 26 Feb 2014 11:28:49 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WIhLZ-0005pP-Ia for emacs-devel@gnu.org; Wed, 26 Feb 2014 11:28:43 -0500 Original-Received: from randomsample.de ([5.45.97.173]:52861) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WIhLZ-0005nN-94 for emacs-devel@gnu.org; Wed, 26 Feb 2014 11:28:37 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=randomsample.de; s=a; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID:Date:References:In-Reply-To:Subject:Cc:To:From; bh=2Kd1KX2CChgxxOc7yqYh1eqdyoqKhbhh0HO/oIIcmu8=; b=h+AsYr1Y79cdLxiZZ4D/3H9k5X5o+PCgE5fxwUzwVHW+6dOdBzfaLEdGmlL+OVTCiXsJgmQJVh03izi82ck+qE174fwtqwpkLp3J+GfjcpyCzk4aQlcCsCFZaaM+QOUV; Original-Received: from dslc-082-083-054-035.pools.arcor-ip.net ([82.83.54.35] helo=spaten) by randomsample.de with esmtpsa (TLS1.2:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.80) (envelope-from ) id 1WIhLR-00060Z-L4; Wed, 26 Feb 2014 17:28:30 +0100 In-Reply-To: <871tyqes5q.fsf@wanadoo.es> (=?iso-8859-1?Q?=22=D3scar?= Fuentes"'s message of "Tue, 25 Feb 2014 23:36:33 +0100") User-Agent: Gnus/5.130008 (Ma Gnus v0.8) Emacs/24.3 (gnu/linux) Mail-Followup-To: =?iso-8859-1?Q?=D3scar?= Fuentes , emacs-devel@gnu.org X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 5.45.97.173 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:169884 Archived-At: =D3scar Fuentes writes: > See this simple example: > > struct A { > int foo(); > }; > > struct B { > int bar(); > }; > > A baz(int); > B baz(A); > > int quux(char c) { > return baz(c). ??????????? > } > > For knowing the correct completion candidates at the point indicated by > the question marks you need to know which `baz' overload to choose, > which in turn requires to know that `c' is a `char' and then knowing > that a `char' is acceptable by the `baz' overload that takes an `int'. > Therefore you know that the correct `baz' overload returns an `A' and > therefore the list of completion candidates is `foo'. With latest Emacs from trunk: - Put the above in file test.c - Load it - M-x semantic-mode - Put point behind "baz(c)." - C-c , l Also, run "M-x bovinate" to see the tags the parser generates. In the function, run "M-x semantic-calculate-scope" to see what it knows there. > Even this very simple case requires knowing the semantics of C++. Even > if this looks approachable by a parser armed with some ad-hoc > heuristics, those will surely fail by just adding/modifying a couple of > lines on the test case above, unless those heuristics implement semantic > analysis under cover. Yes. You will notice that if you change 'quux' to accept a struct A, it will still say 'foo'. But this is actually not a parser problem, but a missing feature in the semantic database, which currently cannot deal with overloads, so it just takes the first one it sees. That should not be very hard to add, but - as usual - someone has to do it. > One was already mentioned by Stephen Leake: refactoring. Actually, > anything that requires semantic knowledge of the source code you are > working on. You could ask for a listing of places dependent of word > size, for instance, or highlight the places where certain idiom is used. CEDET will most probably never be able to refactor C++ code, aside from very simple cases. There are very few IDEs out there which even try to do that; from my experience, none of them do it 100% reliably (just bring some meta template programming into the game and see what happens). IMHO, "Refactoring C++" should not be in the job description. -David