Reddit: why aren't people using D?

Steven Schveighoffer schveiguy at yahoo.com
Sat Jul 25 11:25:40 PDT 2009


Walter Bright Wrote:

> Steven Schveighoffer wrote:
> > On Fri, 24 Jul 2009 14:10:59 -0400, Walter Bright 
> > <newshound1 at digitalmars.com> wrote:
> >> That's my problem with properties as a distinct syntax - they don't 
> >> have distinct uses or behaviors.
> > 
> > If you delineate what can be called how, then you elminate syntax 
> > ambiguities from occurring, and eliminate bizarro cases of syntax.  The 
> > difficulty is that the "human meaning" of a property is different than 
> > the human meaning of a function.  To the compiler, they're all 
> > functions, so you as the compiler writer aren't seeing that they are 
> > different.  I think we all agree that writefln = "hi"; makes absolutely 
> > no sense to a person.  But it makes complete sense to the compiler, 
> > because it has no idea what the word "writefln" means to a person.
> 
> But when I suggest a restriction on properties, I get complaints that 
> someone might want to have them do what functions do. So I fail to see 
> what rule distinguishes them from functions, even for people.

The only thing that properties can't do that functions can is be called with parentheses.  The only thing that functions cannot do that properties can is be called without parentheses (assuming properties are separated from functions)

I fail to see any issues there.  Where are these complaints you speak of?  I've not seen any.

> > It's the exact same reason + is not the concatenation operator.  
> > Semantically, making + concatenate two strings together would be 
> > completely unambiguous from adding two integers together because strings 
> > do not define addition, and integers do not define concatenation.  From 
> > your own documentation, someone seeing "10" + 3 might think that he 
> > would get 13 or "103".  Even if the compiler defines what "should" 
> > happen, and the rules are unambiguous, it looks incorrect to the user.
> 
> Using + for concatenation is syntactically ambiguous with vector addition.

OK, but assuming you didn't have vector addition (which you didn't have up until a few months ago), then how is this a different scenario than the property issue?  Isn't it also ambiguous when you want to call a delegate/function returned from a property?

Besides this, I like what another poster brought up better -- array indexing is the same as functions too, they take a single parameter, and return a value.  So why do we have two different syntaxes for arrays and functions?  Why do we have a special syntax for opIndex but no special syntax for properties?  They're all functions, right?

-Steve



More information about the Digitalmars-d mailing list