Why not Reason's `->` for the method syntax?

This would allow using it with imported functions:

a->@lib.method(3)

Also, it wouldn’t lead to conflicts with field names:

struct User {
  id: Int
  name: String
  mut email: String
}

fn name(self: User) -> String {
  self.name
}

fn init {
  let user = { id: 0, name: "John Doe", email: "john@doe.com" }
  println(user->name())
}
1 Like

Thank you for reaching out with your question about the -> operator. You’re correct in noting that the -> operator, as found in languages like Reason, is a form of syntactic sugar that can make code more concise and often more readable.

We’re always looking to enhance Moonbit and appreciate suggestions that could improve the developer experience. While the -> operator isn’t currently supported, we definitely recognize its utility and appeal. It’s on our radar as a potential feature to consider for future versions of the language.

Stay tuned for updates, and thanks again for contributing to the conversation and helping us shape the future of Moonbit!