I would personally not go for ‘catch’ since its two current uses are for exception handling whereas here it’s not the case at all.
On Fri, Oct 23, 2020 at 00:47 José Valim <[email protected]> wrote: > > >> I don't know if we have a problem with introducing 'else' as a keyword. >> Will that potentially break old existing code? >> > > If a new keyword is a contention point, "catch" can be one option: > > change_and_backup(File) -> > begin > {ok, Value} <~ file:read_file(File), > NewValue = do_something_with_value(Value), > ok <~ file:write_file(File ++ ".backup", Value), > ok <~ file:write_file(File, NewValue), > NewValue > catch > {error, Reason} -> erlang:error({backup_error, Reason}, [File]) > end. > > Use begin/catch for local/functional returns and try/catch for > non-local/imperative returns. It may even make it clearer they are two > approaches for tackling the same problem. > > _______________________________________________ > eeps mailing list > [email protected] > http://erlang.org/mailman/listinfo/eeps >
_______________________________________________ eeps mailing list [email protected] http://erlang.org/mailman/listinfo/eeps
