new DIP5: Properties 2

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Fri Jul 31 13:53:12 PDT 2009


Steven Schveighoffer wrote:
> Hm... in C++, I don't think that convention is checked at all.  For 
> example, I can do template<class T> and specify int as the T, and 
> everything compiles.

Yah.

> But in the case of properties only allowed without parens, functions 
> require parens, you are defining a rule for the compiler.  Think of the 
> parentheses as an extension of the function name, like punctuation.

But you say no parens means query, parens means action. This is sheer 
unchecked convention.

> Like the word "so":
> 
> so!
> so?

so? :o)

> Two different meanings, same word.   Analogously to our property
> discussion, the compiler can know that one is an exclamation, and one is 
> a question, but doesn't really know the meaning of "so!" or "so?".  It 
> can enforce that you use a question where a question is needed, and an 
> exclamation where an exclamation is needed.
> 
> But a person sees it immediately and understands the difference in the 
> implied meaning.  The parens-means-function and 
> lack-of-parens-means-field convention is well well established (except 
> for D) as something that works, I don't think you would have the same 
> confusion as your typename/class example.

Maybe less confusion, definitely more burden.


Andrei



More information about the Digitalmars-d mailing list