Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
User name:
Password:
Save Password
Forgot your password?

 All Forums
 Visual Assist
 Feature Requests
 postfix completion
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Adequat
Tomato Guru

182 Posts

Posted - Feb 25 2018 :  08:43:28 AM  Show Profile  Reply with Quote
The trend is to use free functions, but this needs special support for autocompletion. See what can do one of your competitor:

https://d3nmt5vlzunoa1.cloudfront.net/rscpp/files/2017/04/FreeFunctionCompletion.gif

Free function usage is discussed here:
https://www.reddit.com/r/cpp/comments/7znk3n/free_your_functions_klaus_iglberger_meeting_c_2017/

feline
Whole Tomato Software

United Kingdom
19022 Posts

Posted - Feb 26 2018 :  07:25:10 AM  Show Profile  Reply with Quote
Interesting, are you using a lot of free functions in your code? I was not aware this was a trend, but there is always something new to learn.

Are these free functions placed into a namespace? Or are they in the global namespace?

Also, what happens with different numbers or types of parameters? The example in the GIF is interesting, and it shows the behaviour very clearly, but if I understand correctly, it also assumes / requires that all of the free functions take a single (or at least the first) parameter of the filesystem type. I haven't watched the video yet, but I do wonder how widely this idea can be applied. At least in my experience nearly every "class" (group of related functions) I have also have some data that goes with them, making a traditional class implementation make sense.

zen is the art of being at one with the two'ness
Go to Top of Page

accord
Whole Tomato Software

United Kingdom
3287 Posts

Posted - Feb 26 2018 :  11:55:38 AM  Show Profile  Reply with Quote
We're considering to implement this at some point:

case=101652
Go to Top of Page

Adequat
Tomato Guru

182 Posts

Posted - Feb 27 2018 :  01:20:34 AM  Show Profile  Reply with Quote
quote:
Are these free functions placed into a namespace? Or are they in the global namespace?

Both cases are possible.

quote:
what happens with different numbers or types of parameters?

Does not matter, because only the first parameter is important.

The pattern is this:

someFunction(myobject, arg2, arg3, ...)

if you type:

myobject.

then the list of all functions that use myobject as first parameter, are proposed.

quote:
in my experience nearly every "class" (group of related functions) I have also have some data that goes with them, making a traditional class implementation make sense.

This makes sense at first sight... but this complicates things when the class grows and grows. I personally maintain a 2 million lines application with big classes, and have started to refactor some parts with free functions.

If you have time, look at the video, it is enlightening and a good summary on the topic.

This is a not a new topic actually. It all started in 2000, from an article of the respected C++ guy Scott Meyers.
http://www.drdobbs.com/cpp/how-non-member-functions-improve-encapsu/184401197?pgno=3

I believe it gains momentum these days because programs become more complex and many programmers start to realize (some of) the advantages of the functional programming approach.
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
19022 Posts

Posted - Feb 27 2018 :  07:01:17 AM  Show Profile  Reply with Quote
The feature request already handles the extra parameters, which is good to know. I was wondering how this part was going to work, so I am glad this is covered properly.

Big classes are always going to be a problem, along with big functions. I have come across a few big functions that just make sense as one block, even though it can make it hard to work with them. Beyond this, it is easy to say refactor and break things up sensibly, but its sometimes easier said than done.

I have some of Scott Meyers books, a very good author with a lot of very interesting things to say! Mainly I just wanted to understand the thinking a bit better here, some ideas look good at first, but don't work so well when studied.

zen is the art of being at one with the two'ness
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000