in reply to Re^6: Anybody use !!
in thread Anybody use !!
"If you've learnt to understand it, why do you assume others will be unable to?"
That was not the point. Where this got started, I said that !!$return is a bad idea. The statement essentially returns a flag (boolean) value. Some prior statement should have made to make the return value crystal clear and given it another name other than $return: like $all_accounts_valid or whatever fits the application.
So the first style point is that $return doesn't describe what it is. Yes it is a return value, but what kind of return value? One line of code before the return was needed in my opinion to turn this into a boolean return value.
If you don't agree that using a better name than $return is "easier to understand" and a better style, then things degenerate from there and I have no hope of convincing you otherwise. And yes this will require one statement before the return to make this clear. But..
return $all_data_valid; is better in my opinion than:
return !!$return; There is no need for this confusing !!$return.
This is not a point of whether !!$return can be understood, the point is that there are easier ways of expressing this idea so that it can be easily understood. A Perl return scalar doesn't have a type declaration like in C. Often that very last return line has a lot of contextual meaning. returning a flag like: $all_data_valid is just going to convey more information than !!$return.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^8: Anybody use !!
by BrowserUk (Patriarch) on Dec 30, 2010 at 13:29 UTC | |
|
Re^8: Anybody use !!
by Anonymous Monk on Dec 30, 2010 at 11:49 UTC |