Weird template error

Janderson ask at me.com
Wed Nov 19 22:33:29 PST 2008


Denis Koroskin wrote:

> But you are well aware of _other_ cases in which you _have to_ put an 
> extra pair of parens to access some property method/field thus broking 
> an encapsulation and preventing the class designer to replace properties 
> with fields and vice versa at a later stage.
> 
> It's simply broken! You say that empty pair of parens is equivalent to 
> none of them and thus it is allowed to omit them, but it's not true at 
> all. There are lots of examples where "auto foo = bar();" != "auto foo = 
> bar;" and "auto foo = obj.bar();" != "auto foo = obj.bar;" (delegates, 
> class/struct instances with overloaded opCall, etc).
> 
> - such a duality is confusing (when may you omit the parens and when you 
> may not?)
> - it makes the language more complex (rules are so complex that hardly 
> anyone fully understands them)
> - it leads to code inconsistency (half of the programmers remove an 
> "extra" pair of parens and other half preserve them)
> - it is a source of many compiler bugs (this and lots of related ones)
> - it contributes to user code bugs that are hard to find at times 
> ("oops, I missed a pair of parens. God, I thougth that they were 
> optional").
> 
> IIRC, true property syntax was a #2 wish among the community according 
> to a recent "Top 5 D problems" poll and now that a Tango/Phobos common 
> runtime is implemented it becomes #1.
> 
> I really wish I could understand Walter arguments against proper 
> properties in D...

Some good points.

-Joel



More information about the Digitalmars-d mailing list