Make function application left associative so it can be chained #9223
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
A point where Erlang has always broken the Principle of Least Astonishment is in function application. You would typically expect (particularly in a functional language) that if a function call returns another function, you can apply it directly by appending another set of arguments within parentheses, but in Erlang, you are also forced to put the first function call within an extra parenthesis, like so:
(f(X))(Y)
, rather than the expectedf(X)(Y)
. For example,(accessor(Path))(Thing)
. This can get tiresome when you're working with higher order functions, and sometimes actually obscures the fact that a function application is happening, due to the extra parentheses acting as camouflage.The fix is easy, and since it has not been allowed before there is no existing code where this would change the meaning. It however required me to slightly refactor the
remote_expr
part of the grammar to fix conflicts. It turned out this could also easily be relaxed, so that you can writeget_callback_module(State):callbackFunc(...)
instead of the current(get_callback_module(State)):callbackFunc(...)
.