in reply to Re^3: Assigning default values to function arguments which may be �empty�
in thread Assigning default values to function arguments which may be “empty”

@BrowserUk,

Well, from your choice of function names, I see you have a strong negative opinion about the choice. I, respectfully, disagree.

Firstly, your f2() solution is great and on target. But, I'm a language polyglot, using perl to a moderate extent... not an expert, by far. And to me, the f1() version using List::Util is easier to read and understand at a glance. I also like that it doesn't have an extra visible temporary variable, not for performance reasons, but to minimize the chance for error when reusing the idiom.

Your performance argument, while well proven and valid from the viewpoint of that single line, doesn't hold up when looking at the use of the function or script as a whole. It's a premature optimization. There is literally no perceptible (or even measurable) difference in the script execution performance between any of the solutions presented. It's fun to analyze and debate. But, until I see some sort of real performance bottleneck by the function using this idiom during some actual use, I'm leaning to the side of easier comprehension (again, for me).

But, thank you, for applying your brain power to this... as always, I enjoy reading and learning from your comments.