Should all functions return values?
The suggestion has been made: should all functions return values? It is interesting to consider, and I am looking for your comments on this topic.
Actually, it turns out that all functions actually do return values internally in existing versions of REBOL. But, some functions return the unset value, which makes it appear as if the function returned no result.
The argument in favor of making all functions return arguments is primarily from usage cases such as:
if error? err: try [write %file data] [...]
The problem here is that write does not return a result, so err variable cannot be set, and most of the time an error will result.
** Script Error: err needs a value
** Near: error? err: try [write %file data]
A small number of other cases exist, such as when using print (which does not return a result).
It would be a simple matter to allow such functions to return a value, probably one of their arguments.
So, what do you think?
22 Comments
|