Proposal request: explicit propreties

Bill Baxter dnewsgroup at billbaxter.com
Tue Apr 1 12:39:10 PDT 2008


Steven Schveighoffer wrote:
> "Bill Baxter" wrote
>> I've also run across cases where the compiler fails to realize it should 
>> call a property method unless you explicitly put the () after it.  I can't 
>> recall exactly where.  That's just a bug, but it is something to consider.
> 
> It's when the object being returned by a property overloads opCall.  The 
> prime example I know is tango's Stdout.newline():
> 
> Stdout("hello").newline()("world").newline;
> 
> If you don't include the extra (), then the compiler thinks you're calling 
> newline("world");
> 
> This is one case where the nature of D properties is exploited in a way that 
> would be unnatural with explicit properties.  newline is clearly not a 
> property, but using it in this way is pretty clear (and convenient).

No, that's not the one I was thinking of.  I have seen cases where the 
terminal () was required.  Next time I run into it I'll try to make a repro.

--bb



More information about the Digitalmars-d mailing list