John C wrote:
Chad J wrote:
John C wrote:
Here's a couple of annoying problems I encounter quite often with D's
properties. Would having some form of property syntax fix them?
1) Array extensions:
class Person {
string name_;
string name() {
return name_;
}
}
auto person = getPerson();
auto firstAndLast = person.name.split(' ');
The above line currently requires parentheses after 'name' to compile.
This one is weird. After defining getPerson() I was able to rewrite the
last line into this and make it compile:
auto firstAndLast = split(person.name," ");
Yes, that's D's special array syntax, where free functions can be called
as if they were "methods" of an array.
Yeah, this is one of those nasty cases where several different features
(optional parentheses on functions & automatic extension method syntax
on arrays) work ok in isolation, but where they have weird wonky
behavior when combined. I've seen this one before.
--benji