Is there some control flow construct which would allow returning from an enclosing block instead of the current function? I am thinking of something similar to COMMON-LISP:RETURN-FROM. For example, it would be useful in early termination, eg in
function matched_positions(keys, argnames) positions = [findfirst(keys, key) for key in argnames] any(positions .== 0) ? false : positions end
which could be rewritten as
function matched_positions(keys, argnames) function _find(keys, key) p = findfirst(keys, key) p == 0 ? return_from matched_positions false : p # hypothetical end [_find(keys, key) for key in argnames] end
I have seen a
Base, so I could probably emulate it, but I am wondering if this is a good idea.