> 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