Do we want functions to act as properties, or merely omit parens for ufcs/chaining?
Chad Joan
chadjoan at gmail.com
Mon Jan 28 16:56:40 PST 2013
Would everyone be able to agree to only use @property functions as
properties? This would still allow omittable parens as a way to make
call-chaining and ufcs nicer.
The limitation this imposes is that
void foo(int a) {...}
void bar(int a, int b) {...}
cannot be called in this way:
foo = 2;
2.bar = 3;
As a consequence, everyone's favorite
writeln = "lolwut";
does not compile.
What is still allowed:
int foo() {...}
void @property bar(int a) {...}
...
int x = foo;
bar = x;
auto r = lets.chain!(q).some.stuff;
Although this seems like a distinction that's been discussed, I could
never really tell if there was consensus on this.
Admittedly, I stopped following the "@property needed or not needed?"
discussion halfway through.
As someone who has taken a stab at doing semantic property rewriting, I
think this is a limitation that could potentially help us in the long
run. It simplifies detection of properties: properties are only the
things explicitly marked as such, and functions with omitted parens can
follow a simpler codepath that the in-depth semantic rewrites can safely
ignore.
More information about the Digitalmars-d
mailing list