On Wednesday, 4 January 2023 at 14:21:46 UTC, bauss wrote:
On Wednesday, 4 January 2023 at 03:42:28 UTC, thebluepandabear
wrote:
...
My question is: is there a way to enforce UFCS-syntax?
None of your code actually uses UFCS.
This is UFCS:
```
class Foo {
int bar;
}
void setBar(Foo foo, int value) {
foo.bar = value;
}
void main() {
foo.setBar(100); // UFCS
setBar(foo, 100); // Non-UFCS (Above expands to this)
}
```
This is not UFCS but just class method calling:
```
class Foo {
int bar;
void setBar(Foo foo, int value) {
foo.bar = value;
}
}
void main() {
foo.setBar(100); // Not UFCS - just method call to the class
foo.setBar = 100; // Not UFCS - simply a setter function call
(equal to the above)
setBar(foo, 100); // Error
}
```
Also note that @property doesn't really do anything now and
there's even talk about deprecating it. Althought I personally
still use it, then it doesn't have much of a function and none
of your code is affected if you remove it.
Yeah I got mixed up.
I think a good use of `@property` is for code clarity, it makes
it clear which parts of your code should be treated as properties.