From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ernesto Durante Subject: Re: babel: ob-C with Visual C++ and compilation-mode Date: Wed, 13 Aug 2014 22:58:23 +0200 Message-ID: <87zjf8cdjk.fsf@gmail.com> References: <878un4ut6c.fsf@gmail.com> <53E91C32.4000002@free.fr> <87lhqt6b0w.fsf@gmail.com> <53EA8F2B.7010205@free.fr> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:51666) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XHfcy-0005TP-DZ for emacs-orgmode@gnu.org; Wed, 13 Aug 2014 16:58:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XHfcp-0003yH-CN for emacs-orgmode@gnu.org; Wed, 13 Aug 2014 16:58:36 -0400 Received: from mail-we0-x22c.google.com ([2a00:1450:400c:c03::22c]:63579) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XHfcp-0003y5-5O for emacs-orgmode@gnu.org; Wed, 13 Aug 2014 16:58:27 -0400 Received: by mail-we0-f172.google.com with SMTP id x48so270311wes.17 for ; Wed, 13 Aug 2014 13:58:26 -0700 (PDT) Received: from localhost.localdomain (col74-1-88-183-113-172.fbx.proxad.net. [88.183.113.172]) by mx.google.com with ESMTPSA id co6sm6778203wjb.31.2014.08.13.13.58.24 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Aug 2014 13:58:25 -0700 (PDT) In-Reply-To: <53EA8F2B.7010205@free.fr> (Thierry Banel's message of "Wed, 13 Aug 2014 00:03:23 +0200") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org Thierry Banel writes: >> I have identified a minor bug. When a source code block has the mode >> cpp, we cannot expand the code or more precisely the code is not >> expanded in the correct way because the following function is missing >> >> (defun org-babel-expand-body:cpp (body params) >> "Execute BODY according to PARAMS.This function calls `org-babel-expand-body:C++'." >> (org-babel-expand-body:C++ body params)) > Thanks for reporting this ! You may consider submitting a patch for this > bug. The comment "Execute BODY ..." should be changed to "Expand BODY ...". > >> Ok I will change the comment >> Best >> Ernesto > You are very welcome > Thierry Thank you Thierry for your answer and all the details. I really want to be a contributor and help ob-C to improve (as well as can do a modest lisper). I tried to find a way to master Cx11 and babel is helping me a lot. I think babel can really accelerate learning and dissimation of C++. In this perspective, I have another very simple idea that I want to share with you. I find C++ too noisy. In the following piece of code I really find the presence of the main call and the return statement really annoying and useless. #+begin_src C++ :includes '( ) :results silent template auto compose(T1 t1, T2 t2) -> decltype(t1 + t2) { return t1+t2; } int main() { auto d=compose(std::string("ola"),std::string("ciao")); //d's type is std::string auto i=compose(4,2); assert(d== std::string("olaciao") && i==6); return 0 } #+end_src We can remove it by letting ob-C do the work by modifying the function org-babel-C-ensure-main-wrap. Now the code looks (according to me) easier to read #+begin_src C++ :includes '( ) :results silent template auto compose(T1 t1, T2 t2) -> decltype(t1 + t2) { return t1+t2; } template <> int compose(int t1,int t2) { return t1+t2; } ////main//// auto d=compose(std::string("ola"),std::string("ciao")); //d's type is std::string auto i=compose(4,2); assert(d== std::string("olaciao") && i==6); #+end_src What do you think ? Best Ernesto