Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make function application left associative so it can be chained #9223

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

richcarl
Copy link
Contributor

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 expected f(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 write get_callback_module(State):callbackFunc(...) instead of the current (get_callback_module(State)):callbackFunc(...).

Copy link
Contributor

github-actions bot commented Dec 19, 2024

CT Test Results

    2 files     96 suites   1h 7m 41s ⏱️
2 173 tests 2 125 ✅ 48 💤 0 ❌
2 536 runs  2 486 ✅ 50 💤 0 ❌

Results for commit d6dc8cf.

♻️ This comment has been updated with latest results.

To speed up review, make sure that you have read Contributing to Erlang/OTP and that all checks pass.

See the TESTING and DEVELOPMENT HowTo guides for details about how to run test locally.

Artifacts

// Erlang/OTP Github Action Bot

@IngelaAndin IngelaAndin added the team:VM Assigned to OTP team VM label Jan 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
team:VM Assigned to OTP team VM
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants