You can always return whatever you want in void context. It's unimportant. The one thing that might be smart, however, is that if your return value requires a lot of work to create, and you're just going to throw it away, it might be wise to not create it in the first place, in that context.
Examples of this include the generation of a long list, when there are times that you don't use the list. Or times when the single scalar return value has taken a lot of work to generate. If you can detect early on that the return value isn't needed, you can save a few cycles by not generating it.
Of course this discussion could already be construed as premature optimization. There's no need to complicate things unless you know that the creation of a return value in void context is specifically creating a bottleneck.
Dave
In reply to Re: OK to always return a value?
by davido
in thread OK to always return a value?
by doran
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |