remove usage of method as function #2151
Merged
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.
Previously, methods defined as
fn f(self : T, ..)
are considered both method and regular function. While this allows convenient ways of calling method via@pkg.meth(..)
, it also complicates the semantic of MoonBit.The latest release of MoonBit now supports partial dot application (
_.meth(..)
) and piping into dot application (expr |> _.meth(..)
), which significantly reduce the need for calling methods as regular functions. So we decided to deprecate the behavior of calling methods as regular functions, to simplify the language.This PR removes usage of calling method as regular function in core. In next week's release, we will start emitting warnings on such usage. We are also simplifying the syntax of MoonBit's method system, the simplified syntax will also be available next week.
For most cases, this PR just migrates regular function apply to dot apply. However, for math related methods (
Double::sin
, for example), people are more used to function call stylesin(..)
from math notation, compared of dot apply stylexx.sin()
. So anfnalias
is provided for math related functions and several others, such asRef::swap
.