home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.c++.moderated      Moderated discussion of C++ superhackery      33,346 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 31,708 of 33,346   
   Dave Abrahams to All   
   Re: "for_each + lambda" vs "ranged for"   
   30 Nov 11 19:34:34   
   
   8617d807   
   From: dave@boostpro.com   
      
   on Wed Nov 30 2011, ethouris  wrote:   
      
   > On 19 Lis, 22:35, Dave Abrahams  wrote:   
   >> on Fri Nov 18 2011, ethouris  wrote:   
   >   
   >>   
   >> >> For one thing, for loops can have jump statements (such as "break",   
   "goto",   
   >> >> or "return") leading out of them, for which lambdas have no equivalent.   
   >>   
   >> > This problem can be solved by exceptions (Tcl is using this method -   
   >> > in this language "break", "continue" and "return" are not keywords,   
   >> > but - using C++ nomenclature - functions that throw exceptions, caught   
   >> > next by the enclosing function, such as "while", "for" and "foreach").   
   >>   
   >> Python does that too, but the efficiency characteristics of exceptions   
   >> in C++ are generally so heavily biased to the non-exceptional code path   
   >> that this really wouldn't be appropriate without some magic ability to   
   >> compile those exceptions differently.   
   >   
   > At least there is a chance, if throwing and catching occurs in the same   
   > physical function, and this may happen in this case, if the compiler can   
   > inline the lambda function.   
      
   Inlining the function would make no difference on most compilers because   
   it would be swamped by the cost of throwing the exception.   
      
   > The problem is, however, what to do in case when the exception slips   
   > through for_each's hands - in particular, whether a compiler is still   
   > able to shorten the exception object creation.   
      
   I don't know what you mean by "shorten".   
      
   --   
   Dave Abrahams   
   BoostPro Computing   
   http://www.boostpro.com   
      
      
         [ See http://www.gotw.ca/resources/clcm.htm for info about ]   
         [ comp.lang.c++.moderated.    First time posters: Do this! ]   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca