Today's vocabulary word is "divergent" ... a description for when a function never returns a result in a "normal" way.
All functions that can FAIL or be THROWN or RETURN'd across have divergence as an option (which is, right now, all functions). But it becomes an issue of what to say when there really is no type a function ever returns...what do you put in the spec?
Lately I've been using just [return: []]
. That seems pretty solid. An empty block indicating there's no types you can return...so any return would generate an error.
But because I can imagine people not knowing what that meant, I find myself always adding a comment so people can look up the term "divergent":
catch [
my-non-returning-function: func [
return: [] ; divergent
][
if now/month = 8 [
return "It's August" ; oops, meant THROW (so causes error)
]
throw "It's not August"
]
my-non-returning-function
]
My tendency to hedge is probably silly. Because return: []
is pretty straightforward. The comment probably makes it more confusing.
So return: <divergent>
(or whatever) is probably not worth it.
(I should point out that it hasn't always been as clear that return: []
wouldn't mean something like "the function is invisible" or "the function returns trash". But we have good clear ways of saying those things, so I like this for divergence.)