Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
 All Forums
 Visual Assist
 Feature Requests
 auto insert lambda function parameters

You must be registered to post a reply.
Click here to register.

Screensize:
UserName:
Password:
Format: BoldItalicizeUnderlineStrikethrough Align leftCenterAlign right Insert horizontal ruleUpload and insert imageInsert hyperlinkInsert email addressInsert codeInsert quoted textInsert listInsert Emoji
   
Message:

Forum code is on.
Html is off.

 
Check to subscribe to this topic.
   

T O P I C    R E V I E W
joostn Posted - Mar 13 2015 : 07:26:02 AM
Maybe the idea is completely wild, but this would be handy for me:

If I have a function which takes a std::function<> as a parameter:
void f1(std::function< T1<A>(const T2&) > func);

it would be nice if VAX could generate the lambda parameters for me as soon as I begin a lambda function:

f1([


would expand to

f1([](const T2& param1) -> T1<A>{
})
6   L A T E S T    R E P L I E S    (Newest First)
feline Posted - Mar 14 2015 : 8:49:26 PM
Having done some reading up on C++ and Lambda functions I can now see what you are talking about, and this does make sense, so I have put in a feature request for this:

case=88468

Thank you for taking the time to explain. I am not sure how likely we are to do this, but it does seem worth considering, especially since we are starting to see more interest in lambda's.
joostn Posted - Mar 14 2015 : 02:15:08 AM
The function call. More specifically I would like VAX to generate the second parameter in the GetWebPage function call.

So when I start typing this:
client.GetWebPage("http://www.wholetomato.com/", [

VAX could suggest to expand it to this:
client.GetWebPage("http://www.wholetomato.com/", [](const std::string &){}

The lambda signature can be derived from the std::function<> parameter definition.

Again, the lambda is not the only possible parameter for GetWebPage, I might want to pass a pointer to static function instead, so it should be presented just as a suggestion. But once you start using lambdas this becomes a common pattern.
feline Posted - Mar 13 2015 : 8:58:23 PM
This example makes the code clearer, but does not help me understand what you are after here. Are you wanting help generating a function implementation, or a function call?

I am not sure how we could help you generate the function call, since how would we know what to use as the parameters?
joostn Posted - Mar 13 2015 : 5:07:05 PM
Here's a more concrete example:

class HttpClient
{
  public:
    void GetWebPage(const std::string &url, std::function<void(const std::string &)> callback);	
};


HttpClient client;
client.GetWebPage("http://www.wholetomato.com/", [](const std::string &result){
  // this gets called asynchronously:
  std::cout << result;
});


Here it's pretty simple, but I'm using templated classes and smart pointers, and spelling out the lambda signature becomes more tedious.

And you're right, the std::function does not necessarily have to be filled by a lambda function but it is a common pattern. So I thought it might be suggested as soon as the [ is typed, or as a smart suggestion after entering the comma.
feline Posted - Mar 13 2015 : 4:33:26 PM
I need a better idea of what you are thinking here before forming an opinion on this.

Your code samples read like a function declaration and implementation. Yet the implementation, if that is what it is, does not match the declaration. So what is going on here?

I don't really know anything about lambda's yet, it is something I need to read up on. But a quick search for std::function says that this can contain functions, classes or lambda's. So we don't get to just assume that a std::function contains a lambda.
joostn Posted - Mar 13 2015 : 07:28:44 AM
..or maybe not autocomplete the lambda function, but offer it as a smart suggestion when typing f1(

© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000