-
Notifications
You must be signed in to change notification settings - Fork 121
remove usage of method as function #2151
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
base: main
Are you sure you want to change the base?
Conversation
Math-related method usage inconsistencyCategory Complex conversion logic could be simplifiedCategory Potential missing function aliasesCategory |
Pull Request Test Coverage Report for Build 6867Details
💛 - Coveralls |
@@ -23,7 +23,7 @@ Unit values can be converted to strings using either the standalone function or | |||
test "unit string conversion" { | |||
let u = () | |||
// Both ways produce the same result | |||
inspect!(@unit.to_string(u), content="()") | |||
inspect(u.to_string(), content="()") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing !
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I just saw the latest commit that removed the !
.
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
.