4 ms·
> How would you write that, if the field access was spelled `self.foo`? The language wouldn't be able to tell that you're not just recursively calling the gette
by iudqnolq 3y ago
> How would you write that, if the field access was spelled `self.foo`? The language wouldn't be able to tell that you're not just recursively calling the getter!
You can require parentheses for method calls put methods and fields in separate namespaces.
https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=5264fbd42d4c90e1ee5f827eaeae5b6c https://play.rust-lang.org/?version=stable&mode=debug&editio...
Elixir supports paren-free calls but the default linter and formatter won't let you use them except for a few whitelisted DSLs. I've never missed not having them.
- derefr 3y agoIn languages that require parens for method calls, not using them usually gets you a method handle. Which is still in conflict with a field reference — usually because methods are just function-pointer-typed static fields.
- iudqnolq 3y agoThat's why I said "you can" rather than "you must". And linked to an example that of a language with the property I described.