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 32,515 of 33,346   
   Richard Damon to Kaba   
   Re: Return-type deduction for all functi   
   11 Aug 12 15:16:48   
   
   From: news.x.richarddamon@xoxy.net   
      
   On 8/10/12 5:35 PM, Kaba wrote:   
   > 10.8.2012 21:19, Francis Glassborow kirjoitti:   
   >> On 09/08/2012 19:51, Kaba wrote:   
   >>> Would it make sense to generalize the implicit return-type   
   >>> deduction of the lambda functions to all functions? Motivation:   
   >>> reading the Boost.Proto documentation and seeing something like   
   >>> this:   
   >>>   
   >> But the problem is that only a function declaration is needed in   
   >> order to call a function. How will the caller know what the return   
   >> type is?   
   >   
   > Perhaps the exact type is not always important to the user, such as in   
   > this Proto-example. What is important though is the underlying concept   
   > the type implements. However, without support from the language the   
   > concept would have to be looked up from the documentation; I could   
   > live with that:) But something like this would be even nicer:   
   >   
   >      auto[Grammar_Concept] f();   
   >   
      
   But to the language/compiler, the type is very important. C++ IS a   
   statically typed language, and all functions have a known (possibly   
   overloaded) type which included the type of all of the parameters and   
   the return type.   
      
   As far as I know, there is nothing useful that the compiler could do   
   with a function for which it does not know the return type of. The only   
   thing that I can think that would even be possible would be to take the   
   address of it, and cast that to some known function type and stored in a   
   pointer to function, since the function to be called is uniquely   
   determined by the parameter signature (we can't overload solely on   
   return type). This pointer to function could be compared to other   
   pointer to functions, but could not be dereferenced for a call without a   
   second cast to the real type of the function, which would require   
   knowing the return type.   
      
      
   --   
         [ 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