dragonchild,
As far as I am concerned, this is still very much in the elementary stages of development so making the code and documentation clearer is a given. As diotalevi pointed out, it may not work that great either. If someone does:
my @ints = grep { int($_) == $_ } @numbers;
my $ave = ave( @ints );
Expecting to get back the average are going to be suprised if it returns a function (there were no integers in @numbers). Explaining in the POD may not be enough and this is something that requires careful consideration.
Thanks for the feedback.
| [reply] [d/l] |
I would be thrilled if you would rename your average function from ave() to avg(). I keep reading 'avenue' when you write 'ave' and I note that the common abbreviation seems to be avg().
| [reply] |
diotalevi,
Your input in the CB the other day was valuable. I had waited a week and thought I had thought things through and I was wrong. If and when this moves forward, I will be sure to make the change.
| [reply] |
I was thinking about this. If I wanted to maintain a running average or running list of unique items (ordered or not) ... I'm probably designing my program around it. Therefore, setting some flag is probably ok with me. What would be wrong with:
use Tool::Box qw( :running_totals )
That was, you provide normal functions as the default (with $ave returning undef or 0 in your example above). But, if someone wants the cool running-totals feature, they can turn it on.
Another possibility would be to provide Tool::Box and Tool::Box::Running_Total. *shrug* I'm just brainstorming here ...
Being right, does not endow the right to be rude; politeness costs nothing. Being unknowing, is not the same as being stupid. Expressing a contrary opinion, whether to the individual or the group, is more often a sign of deeper thought than of cantankerous belligerence. Do not mistake your goals as the only goals; your opinion as the only opinion; your confidence as correctness. Saying you know better is not the same as explaining you know better.
| [reply] [d/l] |
This is a horrible idea. This means I can't read Tool::Box::func( LIST ) and can't know from reading the function name whether it returns the function-appropriate result or an accumulator function. It also means that once I've understood that I'm going to get an average (or whatever), that if I read the function name somewhere else, it doesn't necessarilly mean the same thing. The function in different modes must have different names. You're just making obfuscated code otherwise.
| [reply] [d/l] |
dragonchild,
I like this idea. Basically say there are three modes
- The subs work normally :default
- The subs return functions :functional
- Mix and match :hybrid
Of course, there would be no need to specify :default. Then a note with :hybrid concerning unintentional behavior WRT empty lists. If you want both at the same time then you need to be prepared for unexpected results.
| [reply] |